8 Replies - 8796 Views - Last Post: 31 March 2015 - 08:42 PM Rate Topic: -----

#1 jaedinmnw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-August 13

ValueError: need more than 1 value to unpack

Posted 19 August 2013 - 04:11 PM

Here's an example of the segment that I'm having problems with.

1 from sys import argv
2
3 script, first, second, third = argv
4 
5 print "The script is called:", script
6 print "Your first variable is:", first
7 print "Your second variable is:", second
8 print "Your third variable is:", third 


Python is returning the following: "line 3 in <module> script, first,second,third = argv
ValueError: need more than one value to unpack"

Can someone point out whats going on?

Is This A Good Question/Topic? 0
  • +

Replies To: ValueError: need more than 1 value to unpack

#2 DblAAssassin  Icon User is offline

  • D.I.C Regular

Reputation: 40
  • View blog
  • Posts: 300
  • Joined: 11-May 13

Re: ValueError: need more than 1 value to unpack

Posted 19 August 2013 - 05:15 PM

Here is the Official Documentation, if your interested. Here at Dream.In.Code, we don't like to just point out the problem. We find if we can guide you to the correct way to do things. You'll not only feel accomplished that, you did something that worked. It will also help you know what to look for when you have a problem with any other code in the future; and overall make you a better Programmer.

Could you tell me what the point of the Program is?
You may want to check out this out sys module tutorial.
Read the documents, and answer my question, and I can help you out further if you still need it. :)/>

This post has been edited by DblAAssassin: 19 August 2013 - 05:16 PM

Was This Post Helpful? 0
  • +
  • -

#3 jaedinmnw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-August 13

Re: ValueError: need more than 1 value to unpack

Posted 19 August 2013 - 05:41 PM

View PostDblAAssassin, on 19 August 2013 - 05:15 PM, said:

Here is the Official Documentation, if your interested. Here at Dream.In.Code, we don't like to just point out the problem. We find if we can guide you to the correct way to do things. You'll not only feel accomplished that, you did something that worked. It will also help you know what to look for when you have a problem with any other code in the future; and overall make you a better Programmer.

Could you tell me what the point of the Program is?
You may want to check out this out sys module tutorial.
Read the documents, and answer my question, and I can help you out further if you still need it. :)/>/>

It's for work.
Was This Post Helpful? 0
  • +
  • -

#4 DblAAssassin  Icon User is offline

  • D.I.C Regular

Reputation: 40
  • View blog
  • Posts: 300
  • Joined: 11-May 13

Re: ValueError: need more than 1 value to unpack

Posted 19 August 2013 - 07:25 PM

Oh then, you probably have quite a great knowledge in Python, if you have a job programming it. Sorry if I offended you by posting a link to a tutorial or anything.
Was This Post Helpful? 0
  • +
  • -

#5 jaedinmnw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-August 13

Re: ValueError: need more than 1 value to unpack

Posted 20 August 2013 - 04:33 PM

View PostDblAAssassin, on 19 August 2013 - 07:25 PM, said:

Oh then, you probably have quite a great knowledge in Python, if you have a job programming it. Sorry if I offended you by posting a link to a tutorial or anything.

It's Ok, I figured out that I was writing in 2.7 when I was in a 3.0 Tn.B
Was This Post Helpful? 0
  • +
  • -

#6 DblAAssassin  Icon User is offline

  • D.I.C Regular

Reputation: 40
  • View blog
  • Posts: 300
  • Joined: 11-May 13

Re: ValueError: need more than 1 value to unpack

Posted 20 August 2013 - 05:28 PM

Lol, no joke I was gonna ask you what Version you coding in, and what version you had installed.
Was This Post Helpful? 0
  • +
  • -

#7 Mekire  Icon User is offline

  • D.I.C Head

Reputation: 118
  • View blog
  • Posts: 216
  • Joined: 11-January 13

Re: ValueError: need more than 1 value to unpack

Posted 20 August 2013 - 10:43 PM

View Postjaedinmnw, on 19 August 2013 - 11:11 PM, said:

Here's an example of the segment that I'm having problems with.

1 from sys import argv
2
3 script, first, second, third = argv
4 
5 print "The script is called:", script
6 print "Your first variable is:", first
7 print "Your second variable is:", second
8 print "Your third variable is:", third 


Python is returning the following: "line 3 in <module> script, first,second,third = argv
ValueError: need more than one value to unpack"

Can someone point out whats going on?

This program is meant to be run from the command line with three command line arguments.

e.g.:
python myscript.py arg1 arg2 arg3
since the code is expecting these arguments you get an error when you try to unpack values that don't exist.

-Mek
Was This Post Helpful? 1
  • +
  • -

#8 jaedinmnw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-August 13

Re: ValueError: need more than 1 value to unpack

Posted 15 December 2013 - 09:42 PM

View PostDblAAssassin, on 20 August 2013 - 05:28 PM, said:

Lol, no joke I was gonna ask you what Version you coding in, and what version you had installed.

By the way, that was a joke.
Was This Post Helpful? 0
  • +
  • -

#9 rompy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-March 15

Re: ValueError: need more than 1 value to unpack

Posted 31 March 2015 - 08:42 PM

I had that problem using Zed Shaws book. Now I forgot how to do it, but it's simple after you figure it out. You put the literal name of the python file. Say for instances it's forwork.py. Then you would put in the terminal these words: python forwork.py first second third and put them in the command line itself. No commas or quotes etc.

I'll review that chapter tomorrow, I can't believe I can't remember it already. If you need it quick go to youtube, type python the hard way, barton paulson chapter 10, or maybe 11. He'll walk you through it, and after a few times you get it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1