Python development on Windows [Part 1]:Installing Python
Install Python
Of course before you can setup a decent development environment, you have to install the python runtime. It's an exciting time in python land right now, we have a brand spanking new Python 3, however, a lot of the libraries you may wish to use may not have been ported yet. Python 2.6 might work for you but the last time I tried it, some libs weren't ready for it. This will obviously change over time. For the purpose of this guide we'll use the latest version of the 2.5 release. At this time it is 2.5.4
All releases can be found here.
After it's done downloading, double click to run the installer.
Selecting the default options should be fine in most situations. Unles you tell the installer otherwise it will install everything in c:\Python2.5 . After the installer completes, you can run a little test to make sure everything is ok. Open up a Dos Prompt/Cmd window or whatever it's called now. And type "python" at the prompt.
![[figure 1]](http://blog.sadphaeton.com/sites/default/files/users/user3/fig1.jpg)
As you can see, you are blessed with a friendly error message alerting you to the fact that windows does not know what this "python" is. NO MATTER, we will fix this in the next step by setting an environment variable, and adding it to the path.
PYTHON_HOME environment variable
Out of habit left over from the days where I had to install a bunch of java stuff on windows, I create a SOMETHING_HOME variable for various things i need for software development and then add the variables to the system path. The advantage of using variables is you can change stuff easily without breaking your path. For example, if I suddenly wanted to switch to Python3.0 I would merely change the variable and expect everything to work as I had configured it. You may find that adopting a similar convention yourself, reduces number of ways you can confuse yourself when you are busy version hopping.
A quick note on environment variables... In DOS, or whatever they call it now, you refer to an environment variable by surrounding it with '%" . to try this out, in the cmd window you have open from the previous step, type "echo %PATH%" hit enter and note what you see...
Voila, you should see a ";" delimited set of paths that make up your systems PATH variable. In case you don't know, when you type a command(or double click an icon) in the event that the command does not include the absolute path(or relative path), windows will search the paths in your PATH variable to find the command to run. Right now, the directory where you installed Python is likely not in your path which is why Windows responded with "...is not recognized as an internal or external command..." We will soon fix this for good.
If you've never setup an Environment variable before, you are in for a treat(not really). There are several ways to do it, but for our purposes, going through the GUI is easiest. Whenever you want to manage your environment variables, you can do so by navigating to System Properties-->Advanced Tab-->Environment Variables.(right click "My Computer " select "properties", "Advanced Tab" "Environment Variables" Button).
![[figure 3]](http://blog.sadphaeton.com/sites/default/files/users/user3/fig3.jpg)
Note that you can see variables that are user specific, and variables that are system wide. For simplicity's sake, we'll add to the system variables by selecting the "New" button and adding the variable.
![[figure 4]](http://blog.sadphaeton.com/sites/default/files/users/user3/fig4.jpg)
After clicking "OK" to dismiss the "New System Variable" window and "OK" to dismiss the "Environment Variables" window, you would think you could type "echo %PYTHON_HOME%" and actually get the path you set in your currently open command window. YOU WOULD BE WRONG. From what I can tell the environment is read when the command window starts up. So in order to see what you just effected you need to open up a new one. Do that now and type "echo %PYTHON_HOME%"
Your system should respond by spitting the path you specified back at you. To insure the path is valid you could type "cd %PYTHON_HOME%" and your system should drop you in the c:\python2.5 directory, or whatever directory you setup in your environment variable.
![[figure5]](http://blog.sadphaeton.com/sites/default/files/users/user3/fig5.jpg)
Adding PYTHON_HOME to path
So now you have a PYTHON_HOME environment variable. big deal right? if ou type "python" in a command window, it still won't launch python. That is because we still have to add PYTHON_HOME to the path. When we do that, Windows will be able to locate python and run it.
PATH is an environment variable that windows uses as mentioned before, so as you might guess you can change this variable in the same screens as you did to create the PYTHON_HOME variable. REMEMBER that there should be a ";" between each path.
![[figure 6]](http://blog.sadphaeton.com/sites/default/files/users/user3/fig6.jpg)
After adding %PYTHON_HOME% preceded by a ";" to your path variable,dismissing the "Edit System Variable",window and dismissing the "Environment Variables" open up another cmd window and type "python"
As you can see Windows response is now dramatically different(for the better), it launched the python interpreter. And then I wrote a little helloworld program. To exit the interpreter type CTRL+z.
OK, so what have we accomplished? We installed Python for windows, setup an Environment variable called "PYTHON_HOME" whose value was the path where we installed python, and then added the variable to our system path. Just so windows knows that when you type "python" it knows to launch the python.exe found in your Path somewhere.
In Part 2 we will setup easy_install which is where the real fun begins.
Stay Tuned!!!
Adding Python to Path on Windows 7 error
try this in the command
Thanks for sharing this
Thank you
A lifesaver
ActivePython
Great point
Thanks for informative article
it worked - thanks!
Thanks, but the las part
edit: I solve the problem, i
Well I'm glad to hear it
Hint
Development environment
Portable Python
You can actually roll your
portable python
after hours and hours of searching, i found it
Post new comment