I am facing an extremly tiresome and difficult problem for me, one for which i was anable to find any solution for quite some time, my google searching skills failing me miserably.
I have tried to open a .py file with a single line of code in it
print "Hello"
with various methods, including IDLE (Python GUI), Python (Command Line) and finally, command prompt, but to no avail.
I was eventually able to set the PATH variable in Windows and access the python interpreter through the cmd, but when typing the name of the file I keep getting the same error message:
>>> new.pyTraceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'new
' is not defined
What could I do to solve it, and finally be able to run my .py file?
You should use the plain CMD (command prompt) console, not the python interpreter and then type:
Hope that works!
When you run the Windows python installer, at the point you are asked what to install, usually not visible at the bottom of the list of features is an option to modify the system path. Do this enables you to run the python command from the command line as e.g. python new.py, and also if new.py is in the current directory you can just type new.py to run it :-)
In the command prompt,
If there's an error that python is an unrecognized command, you should add the python install directory to your system path first (in environment variables) and then re-open the command prompt.