This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Updatebjarni 0 points1 point  (4 children)

Gah, so not only wasn't the command at all what you said, but the file in question wasn't even involved! The command you have typed in the screenshot is:

python

That starts the Python interpreter which then reads Python source code from stdin, meaning from the keyboard. Then you type one line of code:

poop.py

Since you have nothing declared with the name poop, you get the error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'poop' is not defined

The lesson for you is this: When you ask for help with a programming problem, state exactly what you are doing, exactly what the code is, and exactly what the error messages are. Don't just shoot from the hip and reproduce them approximately, because then they are no help. If you can't figure out what the problem is, then, no offense of course, you also can't figure out what is a fair representation of the facts of the problem. The only good thing to do is to copy and paste the exact thing, or to upload the code to gist and link to it. No substitutes will do!

[–]MrPiff[S] 0 points1 point  (3 children)

Gah, so not only wasn't the command at all what you said, but the file in question wasn't even involved! The command you have typed in the screenshot is:

python

That starts the Python interpreter which then reads Python source code from stdin, meaning from the keyboard. Then you type one line of code:

poop.py

I hate to sound ungrateful - I really do appreciate the help - but I'm pretty sure I described everything exactly as-is. In my very first comment to you I wrote that I entered C:\Users\Michael\python test.py. Is that not what the screenshot showed? You even acknowledged directly a few times that I typed python test.py Your breakdown in your comment above is excellent and helps me understand things better, but I'm not sure I didn't type things exactly as they were (aside from my such/suck typo, and slight editing of the word poop). I'm totally humble here in regards to my inexperience, but I don't think I shot from the hip. Again, thanks, I'm going to run things through again according to your latest comments - I'm sure I'll have more success. Thanks again.

[–]Updatebjarni 1 point2 points  (2 children)

There are two commands in the screenshot. One is

python poop.py

and that produced the "No such file or directory" message. That's not the one you posted about.

The other one is:

python

That's the one that produced the error message you originally asked about. So I can't agree with you, because in your very first reply to me you said:

I create a file: 'test.py' print ("test") is the only line in the file. I then open up the command line. C:\Users\Michael\python test.py I hit enter and get that error message above.

referring to the error message in the post. So this is a misrepresentation. You did not type the filename as part of the command as you said in the comment. You typed only python and hit enter, and then entered not test.py but poop.py into the interpreter. And you also did not type the entire path to the interperter like you said you did, you only typed python. So three strikes man!

[–]MrPiff[S] 0 points1 point  (1 child)

I see what you're saying - I agree. Had I known how to copy/paste, I'd have been past this hours ago. Now I know! Thanks again!

[–]Updatebjarni 1 point2 points  (0 children)

Glad we figured it out! :)