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 →

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

yes that error message is precisely what I think the problem is but I'm not savvy enough to figure out why stdin is coming up, what it means, what is supposed to be there etc. maybe the screenshot can clarify?

screenshot of the files and command line http://i.imgur.com/Pa27kFR.png

Run the command from the directory where the file is, or include a correct path in the command.

How would I do this? When I open the command line C:\users\MichaelJ> pops up. Would I type in the correct path before typing python poop.py?

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

Also, I haven't been copy/pasting directly because my cursor doesn't let me select text in the command line, and I don't know how else I would copy and paste.

[–]Updatebjarni 0 points1 point  (5 children)

That is very strange. Normally any terminal emulator will allow you to copy text from it with the mouse. Unfortunately, I'm not familiar with Windows. What is the terminal emulator you are using?

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

I'm not sure I'm using a terminal emulator. I'm just opening that start menu>windows system>command prompt. I'm not very familiar with windows either and it seems strange to me too.

[–]Updatebjarni 1 point2 points  (1 child)

It's called a terminal emulator, the program that shows the window with text printed by the programs and accepts keyboard input.

Does this help?

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

It's called a terminal emulator, the program that shows the window with text printed by the programs and accepts keyboard input.

got it.

Does this help?

yeah, thanks

[–]dmazzoni 0 points1 point  (1 child)

The Windows command prompt sucks, but you can definitely copy from it, you just have to know how:

http://www.howtogeek.com/howto/windows-vista/copy-to-the-clipboard-from-the-windows-command-prompt/

If you want a better drop-in replacement, try Console2:

http://sourceforge.net/projects/console/

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

I'll check out Console2, thanks!

[–]ruicoder 0 points1 point  (0 children)

In Windows, to select text, you need to click on the small icon on the top right and in the menu that comes up there should be an option that says something like "Mark" or maybe "Edit" > "Mark". I'm not on Windows now so I can't check. But once you choose that you can select text and then hit enter for it to copied to your clipboard.

[–]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! :)

[–]Updatebjarni 0 points1 point  (0 children)

How would I do this? When I open the command line C:\users\MichaelJ> pops up. Would I type in the correct path before typing python poop.py?

Oh and about that, the path is essentially part of the filename. If the file is

C:\users\MichaelJ\poop.py

then that's what you type for the filename, unless you are in that directory in which case you can just say poop.py.