(Originally adapted and updated from Tom Willis’s posts here and here). Also, as commenters suggested, you should take a look at ActiveState which can probably save you all this trouble…

imagesSetting up Python for development on a Windows environment turns out to be not such an easy task.
After setting up several such environments and running into all sort of problems I had to figure out I decided it would probably be worthwhile for myself and other developers to document the process…

If you’re starting Python development on Windows, and especially if you’re using Google App Engine (as this guide is about Python 2.5.4) this guide is for you…

Install the Python Runtime

The first step in setting up a Python development environment is to install the Python runtime.
For the purpose of this guide we’ll be installing Python version 2.5 (the latest at this time is 2.5.4) as
that’s the version required for Google App Engine development which is my main use for Python (it’s also a mature version, with wide support etc.)

You can find a list of all the Python releases here.
The Python 2.5.4 version is here.

Just download the msi that fits your system and install it.
Unless you chose otherwise, the installer put everything in c:\Python25

Set up your Environment

Setting the PYTHON_HOME Environment Variable

We’ll set PYTHON_HOME to c:\Python25 and add it to the PATH variable:

  • Open the environment variable settings dialog – right-click "My Computer", select "Properties", "Advanced Tab" and click the "Environment Variables" button.
    (Alternatively, on Windows 7 you can just type "edit the system environment variables" on the start menu)
  • Under System Variables click the button New…  and add a variable called PYTHON_HOME that points to c:\Python25
  • Now edit the PATH system variable and add ;%PYTHON_HOME%; to its end.

You can test that you’ve done this correctly by firing up the Commend Prompt and typing "echo %PYTHON_HOME%":


Setting up the PATH variable

The PATH variable is a list of paths separated by a ";" character.
On the same dialog used before, find the PATH system variable, edit it and add ";%PYTHON_HOME%" (notice the preceding ; character).

Now you can run python from anywhere in the system.
Open a new Command Prompt window and type "python" and you should get the Python prompt:


Installing easy_install

What’s easy_install? easy_install makes it easy to fetch and install Python libraries and their dependencies.

Download and run the setuptools installation package for Python 2.5
(when writing this guide, the version was 0.6c11)

easy_install gets installed into c:\Python25\Scripts. As we want it accessible from anywhere we’ll want to add that path to the system’s PATH environment variable.
So, edit the PATH variable again and add %PYTHON_HOME%\Scripts to its end (and don’t forget to precede it with ";")

Now easy_install is available from anywhere:


Now you can install libraries from Python’s library repository. For example you can install Nose simply by running "easy_install nose":


Support Installing C Libraries

One of the features in Python is being able to use code written in C via extensions.
Various libraries make use of this feature (especially for security and scientific calculations).
In order for the libraries distributions to remain platform natural, they’ll usually be distributed with their C source code along with their python source, and require compilation on the target machine when installed.

On Linux and other OS’s this is usually not a problem and the library will build the C extension without an issue. On Windows however, it is likely that there’s no C++ compiler on the system to do this operation.

For example, try running "easy install pycrypto" :


As you can see from the error, the C extension could not be built.
While we can use Visual Studio 2003 to do this, it is way easier (and free) to use MingW32…

Install MingW

Download and install the "Automated MingW installer" from here (if the link doesn’t work just go to http://mingw.org and press the download link on the left)

When you read the "Select Components" part of the setup, make sure both the  "C compiler" and "C++ Compiler" packages are selected.
Once the installation is done, add "C:\MinGW\bin" to your PATH system environment variable.

We now have a C++ compiler for easy_install to use to build C extensions and all we need to to do is tell it to use it instead of Visual Studio 2003. We do this by creating a file called "distutils.cfg" at c:\Python25\Lib\distutils containing the following:


You should now be able to install PyCrypto by running "east_install pycrypto".
You can verify the installation by running Python and trying to import it:

If you didn’t get an error messaging when importing Crypto then PyCrypto is installed correctly.

Install Support for SSL

As mentioned earlier, I’m mostly using Python for Google App Engine development.
To securely communicate with Google’s servers via SSL we’ll need to install SSL support.

The process for enabling SLL is as follows:


Final Words

You have a Python development environment ready! Wasn’t simple, but you did it…
Now I recommend getting a decent IDE..  Try Eclipse with PyDev or JetBarin’s new PyCharm

Similar Posts:

    None Found

Tags: ,

9 Comments to “The Complete Guide to Setting up Python Development Environment on Windows”

  1. Todd | September 23rd, 2010 at 9:14 pm

    Could you mention why you didn’t use the ActiveState Python distribution? It handles most of the environment stuff you went through by itself, plus adds .PY and .PYW to the PATHEXT variable so you can leave off those extensions when starting a script. It also installs pywin32 by default which are extremely useful to have.

    Are you developing commercial software and thus not eligible to use it under their license terms?

  2. Eran Kampf | September 23rd, 2010 at 9:33 pm

    Hey Todd,
    I’ve never used ActiveState Python because I’ve never heard of it until now :)

    When I started Python development (Google AppEngine) a couple of months back I just followed the links provided by the Google and Python tutorials I read (pointing to the official Python stuff) and got by on those.

    I am developing commercial software but I dont see any problem with their license on that regard (see term #1 on http://www.activestate.com/activepython/license-agreement)

    So there’s really no difference between the regular Python distribution and ActivePython except that it handles the Windows setup experience better?


  3. Todd | September 24th, 2010 at 3:26 am

    Previously unknown is a good reason I guess. =) I thought the license was more restrictive, glad to hear otherwise.

    The ActiveState package is the full Python install for that version plus a bunch of stuff. Apart from smoothing some parts of the Windows installation, it also comes with a few popular modules preinstalled, primarily PyWin32 as I mentioned, which gives Python COM and WMI capabilities and access to Windows APIs. It’s also got a very complete help file which contains some popular tutorials and articles along with the full Python help. http://www.activestate.com/activepython

    ActiveState also has their Python Cookbook site with lots of great examples in Python and other languages. http://code.activestate.com/

    For your particular install setup ActiveState wouldn’t really save you many steps, but you still may find it a useful package to start from.

    Great set of steps by the way, especially the C libraries and MinGW. Thank you!

  4. gorlok | September 27th, 2010 at 2:22 pm

    Good article. Another option, just in case: install a Linux distro into VirtualBox (or Vmware, etc) on Windows.

  5. srid | September 27th, 2010 at 10:18 pm

    Hi Eran,

    1. The latest release of the Python 2.5 series is 2.5.5, not 2.5.4

    2. If you install ActivePython, there is no need for the following steps in your blog post:

    a. Setting the PYTHON_HOME Environment Variable
    b. Setting up the PATH variable
    c. Installing easy_install

    ActivePython already does all the above; in addition it also installs `pip`. Generally you do not need a compiler suite such as MinGW, because ActivePython includes a tool called PyPM that makes it easy to install binary packages from the ActiveState repository at pypm.activestate.com. For instance, you can install the PyCrypto module using the following command:

    C:\> pypm install pycrypto

    Look, no compilers needed! And the whole thing took a few seconds to run (dependending on your network connection)!

    You asked “[Is] there really [any] difference between the regular Python distribution and ActivePython except that it handles the Windows setup experience better?”. The answer is: apart from better Windows setup, ActivePython also provides:

    – pywin32
    – Distribute (community based fork of setuptools)
    – pip
    – access to PyPM repositories for installing binary modules

    Note: PyPM repository is not free for 64-bit Windows build; and is only available on 2.6 and above.

  6. Travis | January 30th, 2011 at 8:27 am

    small typo…

    ” You should now be able to install PyCrypto by running “east_install* pycrypto”. ”


    Also for users of Python pre-version 2.6, you’ll encounter some errors with this step of installing PyCrypto…just upgrade…

  7. Travis | January 30th, 2011 at 8:30 am

    Other than that though…lifesaver tutorial. Thanks a million!

  8. Travis | January 30th, 2011 at 8:31 am

    Sorry to string-bet my comments here but…what do you think of NetBeans IDE?

  9. Eran Kampf | January 30th, 2011 at 11:34 am

    Hey Travis,
    Thanks for the comments :)
    I havent tried the NetBeans IDE. I’ve been pretty happy with PyDev on Eclipse…

    Ive recently switched to a Mac but I still find Pydev+Eclipse favorable for Python\GAE development over TextMate which I use for pretty much everything else (Rails etc.)