Python Run Python on Windows: A Beginner's Guide

  • Thread starter Thread starter MaxManus
  • Start date Start date
  • Tags Tags
    Python Windows
AI Thread Summary
To use Python on Windows, it is essential to install the appropriate version, which can be found at python.org. Users often encounter issues when trying to run Python scripts, such as receiving error messages indicating that the script is not a valid Win32 program. This typically occurs due to incorrect environment variable settings. To resolve this, the directory containing python.exe must be added to the system's PATH variable. This can be done by accessing the Control Panel, navigating to System, then Advanced, and finally Environment Variables. In the System Variables section, locate the "Path" variable, edit it, and append the Python installation path (e.g., c:\Python25) with a semicolon as a separator. After saving the changes, users can run Python scripts directly from the command prompt by typing "python kick.py" or simply "kick.py" if the file is executable. Additionally, double-clicking a .py file in Explorer will also launch Python.
MaxManus
Messages
268
Reaction score
1
How do you use Python on Windows? I have Python 2.5.1, but have only tried Python on the school's computers where they use Linux.
 
Technology news on Phys.org
Hi MaxManus,

MaxManus said:
How do you use Python on Windows? I have Python 2.5.1, but have only tried Python on the school's computers where they use Linux.

If you go to

http://www.python.org/download/

you can find a windows installer. Is that what you are looking for?
 
I'm not sure, but I think I have the right programms, but when I write kick.py in the Windows terminal I get an error message. The message is in Norwegian, but it is something like D:\Documents and Settings\My Name\kick.py is not a valid* Win 32-program. I have never tried to run programs on a Windows terminal and have only tried it a couple of times on the school's computers so I don't know how to interpret the message

* not sure about the translation
 
You must put the directory with python.exe (usually c:\python25) in the path.
Go to control panel->system->advanced->edit environment variables and add it to the end of the path entry.

You can then run a file by typing "kick.py" or "python kick.py"
You can also double click on a .py in explorer and it will start python
 
I'm not sure I understand. I went to edit edit environment variables and added Name: "Python" Value: "D:\Conduit Root\python\python-2.5.1\python.exe", but I stil get the same error
 
Last edited:
MaxManus said:
I'm not sure I understand. I went to edit edit environment variables and added Name: "Python" Value: "D:\Conduit Root\python\python-2.5.1\python.exe", but I stil get the same error

I'll tell you the details of how I got I got it working on my system. (If you're not familiar with this, perhaps you want to make a copy of your path before you add to it? Open a command prompt and then type in
Code:
path >> pathbackup.txt
which will put a copy of your path in a text file in your current directory.)




Anyways, what I did was go to:

control panel -> system -> advanced -> environment variables

On the window that comes up, there will be two sections: one for "User variables for <name>" (where <name> is the login name) and one for "System variables".

In the "system variables" window, scroll down until you see "path" under the variable heading. Highlight that line and then press edit.

In the next popup window, I edited "Variable value". Make sure you are at the end of that line (you are just adding to the line, not changing anything that's already there and it can be a long line) and then I typed in exactly


Code:
;c:\Python25

The semicolon separates entries in the path, and on my system python.exepython is located in c:\Python25. Then you can press OK three times.


After that has all closed, open an command prompt window. You can type "path" to see what your path currently is, and at that point I can type "python" to start python, or "kick.py" to start a file.
 
Thank you
 

Similar threads

Back
Top