• Register
1 vote


I am getting an error while I am trying to run a python program. Please have a look at it and give me a solution if possible. I am trying to figure the problem but I fail to do so.

from sys import argv
script, usr_name =argv
prompt = '>'
print "Hello %s, I'm the %s script." % (usr_name, script)

Here is the error, “valueerror need more than 1 value to unpack

Traceback (most recent call last):  
script, usr_name =argv  
ValueError: need more than 1 value to unpack


12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote


Probably you didn't provide an argument on the command line. In that case, sys.argv only contains one value, but it would have to have two in order to provide values for both usr_name and scrip

.Try something like this below:

script, one, two = argv
print "My file is:", script
print "My first entry is:", one
print "My second entry is:", two

I hope you get the point. So, fix the error this way and try to run the program again. Let me know if it works or not. If works, leave a kudos.
You are welcome.

13 9 6
94,240 points

Related questions

0 votes
1 answer 16 views
Problem: i am getting error: ValueError: need more than 2 values to unpack when i run the unit test now, so 2 failures and one skip now as far as i have read about lambda i: get_error_count(self._error_lookup, i)) line 142 of source is the method for test, err, ... = get_error_count(i) reference Python 3.0 has something a bit like this. Excess values can be bound (as a list) to the last variable:
asked Feb 15 Mashhoodch 13k points
0 votes
1 answer 12 views
Problem: How to I Solve this: valueerror: not enough values to unpack (expected 2, got 0) HELP! I need help understanding this: valueerror: not enough values to unpack (expected 2, got 0) Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 6 Mashhoodch 13k points
1 vote
1 answer 137 views
Problem: For the following code I got some error message like: ValueError: not enough values to unpack (expected 3, got 2) The code: import openpyxl, smtplib, sys wbs = openpyxl.load_workbook('duesRecords.xlsx') sheet = wb.get_sheet_by_name('Sheet1') lastCol = sheet. ... problem sending email to %s: %s' % (email, sendmailStatus)) smtpObj.quit() Can anyone help me out to solve this problem?
asked Apr 8, 2020 LizzyM 6.1k points
0 votes
1 answer 21 views
Problem: I get some error that I can't figure out. Any clue what is wrong with my sample code? class B: def meth(self, arg): print arg class C(B): def meth(self, arg): super(C, self).meth(arg) print C().meth(1) I got the sample test code from help of 'super' built-in method.
asked Feb 23 Mashhoodch 13k points
0 votes
1 answer 61 views
Problem: I am learning Python. Recently I got an assignment in which I had to replace some characters of a string with other characters. While searching for the solution on the Internet, I came across the translate() method that can be used to do so. I tried the ... print(string.translate(string ,table)); I do not know why this problem occurs. Can anybody here help me sort out this error? Thanks!
asked Dec 27, 2020 Code Learner 9.2k points
0 votes
1 answer 9 views
Problem: I have this error, and I need to fix it, any help: the truth value of an array with more than one element is ambiguous. use a.any() or a.all()
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 22 views
Problem: I am really confused as to why this error appears. Here is my code: import numpy as np x = np.array([0, 0]) y = np.array([10, 10]) a = np.array([1, 6]) b = np.array([3, 7]) points = [x, y, a, b] max_pair = [x, y] other_pairs = ... 5, 6] not in max_pair) >>>False Why does this happen when using NumPy arrays? not in/inis ambiguous for existence? What is the correct syntax using any()\all()?
asked Jan 26 sasha 16.2k points
0 votes
2 answers 1.9K views
Problem : I got following rather cryptic error message: the truth value of an array with more than one element is ambiguous. use a.any() or a.all()
asked Nov 18, 2019 peterlaw 6.9k points
1 vote
1 answer 3 views
Problem: Any ideas on what I need to do to fix this? python valueerror: too many values to unpack
asked Mar 19 MUHAMMAD MUNEEB 80k points