February 19th, 2005, 11:01 AM
How to run python with command line?
ok, now I can't even run any program in python without pressing the F5.
Normally I press F5 to run the program...but I can't seem to be able to run ANY python with command line.
First, I don't even know where should I type this:
I"m using IDLE. Should I just open the Shell and type python filename.py ??? it doesn't work. I need to know at least how to run the program step by step from command line T_T
Okay, lets say i' ve a python file in C:\windows\desktop\okay.py
How do I run it?
in the shell, but it doesn't run the program...but if i press F5, it can run it.
February 19th, 2005, 11:54 AM
Did you try just reinstalling Python?
February 19th, 2005, 12:20 PM
no, but I'm sure that it's my syntax error. I got an syntax error.
or I should put "python filename.py" in somewhere else..probably not in the shell.
Also, why F5 works for me?
also, if i type "python filename.py" in MS prompt I get an error saying that it can't recgonized the "python" command.
February 19th, 2005, 12:39 PM
Oh now I think of it, probably I install the python properly, but I forgot to set environment variable for my windows XP, so it can't detect the command "python" in command prompt.
Am I right?
How to set up environment variable?
Please show me step by step.
February 19th, 2005, 12:50 PM
Wrong shell . You need to type this at the DOS command prompt rather than in IDLE.
To do this press the Windows-R keys together and type "cmd" in the box that appears – just incase you don't know which the windows key is, its the one with the windows sign on it (next to the space bar).
From here you will probably need to CD to the directory where you installed Python… on Windows this should be something "C:\Python24\" depending on which version you installed .
Now you can type:
Note: you need to replace the path given above with the path to your Python program.
Two alternatives to this would be to move to the directory (using CD) in which your program is located and simply type the files name, or if all else fails double click your program file. Both of these should run the program with whatever Windows associates .py files with – this can be changed if this isn't already Python.
Sorry I can't give you an example of this but I'm not running Python on Windows.
Hope this helps,
February 19th, 2005, 01:04 PM
As far as I can remember it goes like this:
Originally Posted by victorti83plus
Right-click "My Computer" and click "Properties".
Click on the "Advanced" button.
Click "Environment Variables".
Locate the PATH variable and add "C:\Python24\" to it.
Note: replace the path above with the correct installation directory.
Anyway, that should do it but I haven't done this myself in a while so I may be a little off here .
February 19th, 2005, 04:02 PM
thx it works now