Friday, April 27, 2012

Running Python from Command Prompt

Want to run Python on Windows from command prompt? This is a tutorial to set it up. Basically what we will be doing is adding in the Path of the install location of Python to the Windows Environment for command prompt to locate it.

Step 1:

Download Python, As of this writing, version 2.7 is the stable version of Python, so I would recommend downloading that based whether your computer is 32x or 64x.

Once the file has been downloaded, run the installer. Once complete, move to Step 2.

Step 2:

Now to set the PATH in the Windows environment.

    Windows XP:

    - Right click "My Computer" and select Properties.


      - Click on the "Advanced" tab at the top and select "Environment Variables" button.


        - In the list titled "System Variables" scroll down until you see the variable "Path". Select the line and press the "Edit" button underneath. In the pop-up window, click on the second textbox called "Variable value:"  and go to the end of the text. Add the install path directory, if its the default path add this text to it: ";C:\Python27". (Don't forget the delimiter ';' before the path.) Then click "OK"


 

    Windows Vista/7:

     - Click the Start button and right click on Computer. Now click properties in the dropdown as seen                                                       below.


- In the System Settings, press the "Advanced System Settings" link to the left. In the following pop-up press the "Environment Variables" button. Next, in the Environment pop-up, use the second list to find the variable called "Path", select that and press the edit button. Now as seen below, Edit the Variable value by adding the install path directory, if its the default path add this text to it: ";C:\Python27" to the end of the textbox. (Don't forget the delimiter ';' before the path.) Click "Ok" when complete.





Step 3:
Now we are able to run Python from command prompt.
First, open up command prompt:
Windows XP: Click Start and use "Run", Type "cmd" and hit enter.
Windows Vista/7: Click start and type "cmd" and hit enter.

Type in "python" into the window and you should get the following meaning its setup correctly. Now you can run python.


No comments:

Post a Comment