tags:

views:

41

answers:

3

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? like ex 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.

A: 

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.

Veeti
@Veeti I've added it to the path now, but I get some compile errors is it possible that I've downloaded wrong version of the language?
Gandalf StormCrow
Python 3 is incompatible with Python 2. If you're getting runtime errors (hard to get compile errors in Python), you might be running a Python 2 script. A good sign are `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.
Tim Pietzcker
@Tim Pietzcker its like this in the file `print " list - Print summary of existing objects by class"` so its version 2 of the language?
Gandalf StormCrow
Yes it is. Download version 2.6.5 and install it in a different directory - see also here: http://stackoverflow.com/questions/1835930
Tim Pietzcker
A: 

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

TooAngel
+2  A: 

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.

Tim Pietzcker
@Tim Pietzcker I've added it to the path now, but I get some compile errors is it possible that I've downloaded wrong version of the language?
Gandalf StormCrow
Hmm... *Compile* error?
cake