Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Run Python on Windows

  1. Sep 19, 2008 #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.
     
  2. jcsd
  3. Sep 19, 2008 #2

    alphysicist

    User Avatar
    Homework Helper

    Hi MaxManus,

    If you go to

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

    you can find a windows installer. Is that what you are looking for?
     
  4. Sep 19, 2008 #3
    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
     
  5. Sep 19, 2008 #4

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    You must put the directory with python.exe (usually c:\python25) in the path.
    Go to control panel->system->advanced->edit enviroment 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
     
  6. Sep 21, 2008 #5
    I'm not sure I understand. I went to edit edit enviroment 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: Sep 21, 2008
  7. Sep 21, 2008 #6

    alphysicist

    User Avatar
    Homework Helper

    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 (Text):
    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 (Text):

    ;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.
     
  8. Sep 23, 2008 #7
    Thank you
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?