Run Python on Windows: A Beginner's Guide

  • Context: Python 
  • Thread starter Thread starter MaxManus
  • Start date Start date
  • Tags Tags
    Python Windows
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
6 replies · 3K views
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.
 
Physics news on Phys.org
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.