I've downloaded python installer from http://www.python.org/ftp/python/3.1.2/ , this python-3.1.2.msi file, I need to execute some python files? How do I do that? For example in php I'd do php filename.php from console, I do however have python command line but I don't know how to execute those files.
So if I could set ENV variable to directly execute my file(s) if that is possible that would be great.
3 Answers 3
There is an option in the installer called "Register Extensions" to associate Python files with the interpreter, so double-clicking them or entering filename.py in the console should work.
Apart from that you might want to add C:\Python31 to your PATH variable (right-click on My Computer, choose Settings, choose the Advanced Tab - there you can access the system variables. Better do this as an admin.
1 Comment
If you type python in the Windows command line, what happens? Is the Python interpreter in your PATH yet?
If not, add the Python installation directory there (here's a good guide). Then just do python script.py just like with PHP.
4 Comments
print statements - if the syntax used is print "Hello" instead of print("Hello"), then it's a Python 2 script. You can have both versions installed in parallel.print " list - Print summary of existing objects by class" so its version 2 of the language?you can just execute
python yourfile.py
Or if the python command don't work you have to give the absolute path to you python installation or add it to windows path