
metulburr wrote:Then you open a Terminal/DOS prompt and change directory to your test.py and write this:
- Code: Select all
python test.py
micseydel wrote:You should find a tutorial on using the command line on whatever OS you use, namely for commands like cd, ls (Unix [Linux/OS X]) or dir (Windows), pwd (Unix, not sure about Windows though it may be the same). If you're not familiar with file hierarchies yet, as a general computer skill, then you will want to pay attention to those from now on.
cd
"python: can't open file 'ex1.py': [Errno 2] No such file or directory"
python is not recognized as an internal or external command,
operable program or batch file.
M4RTIN wrote:"To make python execute in any directory in Windows. You have to add python to the PYTHONPATH environmental variable. To get there: My Computer > Properties > Advanced Systme Settings > Environmental Variables > create new variable PYTHONPATH and set C:\My_python_lib. Where My_python_lib is the directory of python."
M4RTIN wrote:I want to be able to just make python file then save it and open it in cmd i've been looking for a way to do that for over 5 hours and i still cant find it.
C:\>python.exe C:\my_python_lib\test.py
C:\>cd C:\my_python_lib
C:\my_python_lib>python.exe test.py
@metulburr: you might wanna fix that in the post, as PYTHONPATH is used to look for imported Python modules; see: http://docs.python.org/2/using/cmdline. ... PYTHONPATH. I'm assuming that text talks about finding the Python executable, in which case it should be "PATH", not "PYTHONPATH" (which is still not what OP is looking for).
Might be also worth changing the text to make it more obvious that this will make the Python executable runable from anywhere, not any script.
M4RTIN wrote:"To make python execute in any directory in Windows. You have to add python to the PYTHONPATH environmental variable. To get there: My Computer > Properties > Advanced Systme Settings > Environmental Variables > create new variable PYTHONPATH and set C:\My_python_lib. Where My_python_lib is the directory of python." I want to be able to just make python file then save it and open it in cmd i've been looking for a way to do that for over 5 hours and i still cant find it.
Users browsing this forum: setrofim and 1 guest