1

I'm currently following the book, "Learning Python The Hard Way" and I am stuck trying to make a script run from the command line.

I have saved this text:

from sys import argv

script, first, second, third = argv

print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second
print "Your third variable is:", third 

as ex13.py in my Python folder. When I try to run it from cmd, it comes up with this error:

"File "<stdin>", line 1
python ex13.py first 2nd 3rd
          ^

Can you explain what this means and how I can fix it? Sorry for being a noob :)

0

1 Answer 1

7

It looks like you are typing the line

python ex13.py first 2nd 3rd

into the python interpreter. You are supposed to type that at the cmd prompt.

Sign up to request clarification or add additional context in comments.

2 Comments

I just tried that and it says this "python: can't open file 'ex13.py': [Errno 2] because there is no such file or directory."
James: then you need to cd to the directory containing the script, or use the full pathname.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.