How to install and setup a Python Django development environment on Windows 7

Step 1: Install Cygwin & Python

To get started we need to setup a Python environment running under Cygwin. First make your way over to and run their installer.

Most of the installation is just clicking next, and accepting the defaults:

Cygwin Python Installation 1

Click next:

Cygwin Python Installation 2

Click next:

Cygwin Python Installation 3

Click next:

Cygwin Python Installation 4

Click next:

Cygwin Python Installation 5

Choose your closest Mirror. We like Internode!

Cygwin Python Installation 6

This is where we stop clicking next and select our packages.

Select Python:

Cygwin Python Django Installation - Package Selection 1

We'll probably need to install a Subversion client, so also select that:

Cygwin Python Django Installation - Package Selection 2

wget will make installing the Django stuff easier:

Cygwin Python Django Installation - Package Selection 3

gcc and gcc++ will be needed later to compile some of the Python libraries (eg PIL):

Cygwin Python Django Installation - Package Selection 4

No *nix environment should be without vi, an evil and arcane text editor:

Cygwin Python Django Installation - Package Selection 5

We specifically require libjpeg-devel for compiling the Python Image Library (PIL), which is used by a lot of Python Django projects for image manipulation:

Cygwin Python Django Installation - Package Selection 6

The installer will automatically pull in all the necessary dependencies:

Cygwin Python Installation 7

Creating an icon is probably a good idea:

Cygwin Python Installation 8

You'll probably get this warning message. Just click 'This application installed correctly'. (Windows has no idea what's going on at the best of times):

Cygwin Python Installation 9

The installation is now complete. Double click on the icon on the desktop, and then type python . If the Cygwin / Python environment is successfully setup you should see the following:

Cygwin Python Installation 10

NB: "fatal error unable to remap" or "error: Resource temporarily unavailable"

Note: If you receive an error "fatal error unable to remap" or "died waiting for dll loading" or a similar error then this is probably due to Windows DEP shenanigans causing trouble. First reboot, then run the following command (from a regular cmd.exe shell) before continuing.

C:>cd c:cygwinbin
C:cygwinbin>dash.exe rebaseall

Step 2: Install Python Setup Tools

We need to download the latest version of Setuptools that corresponds to our Python version (2.6)

Open up a bash shell by double clicking the desktop icon. Enter wget and the url of the latest version of setuptools for Python 2.6. You can get the URL from here.

NB. To paste the URL, right click on the left hand top corner of the Bash shell window and select Edit >> paste.


Admin@Win7 ~
$ wget
--2011-01-11 12:22:59--
Resolving (, 2001:888:2000:d::a
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 333447 (326K) [application/octet-stream]
Saving to: `setuptools-0.6c11-py2.6.egg'

100%[======================================>] 333,447     43.3K/s   in 8.9s

2011-01-11 12:23:09 (36.7 KB/s) - `setuptools-0.6c11-py2.6.egg' saved [333447/33

Then install setup tools:

Admin@Win7 ~
$ sh setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /usr/lib/python2.6/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/bin
Installing easy_install-2.6 script to /usr/bin

Installed /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

Next install virtualenv:

Admin@Win7 ~
$ easy_install virtualenv

And virtualenvwrapper:

Admin@Win7 ~
$ easy_install virtualenvwrapper

Step 3: Setup virtualenvwrapper and deploy your project

Add the following configuration to your .bashrc. This will ensure that virtualenvwrapper works as expected:

Admin@Win7 ~
$ echo "export WORKON_HOME=$HOME/projects" >> ~/.bashrc

Admin@Win7 ~
$ echo "source /usr/bin/" >> ~/.bashrc

Admin@Win7 ~
$ echo "export PIP_VIRTUALENV_BASE=$WORKON_HOME" >> ~/.bashrc

Now close your bash shell, and reopen it. This will ensure that the commands you added to .bashrc are loaded.

Let's create your project directory, same as defined in .bashrc.

Admin@Win7 ~
$ mkdir projects
Admin@Win7 ~
$ cd projects

Admin@Win7 ~
$ mkvirtualenv --no-site-packages myproject

Admin@Win7 ~
$ cd myproject

If you get this far without errors then your project has been created and you're ready to start working on it.

You should see your bash prompt change, when you start working with your project:

Admin@Win7 ~
$ cd myproject

Admin@Win7 ~
$ workon myproject

Admin@Win7 ~
$ cd myproject

Now is probably a good time to install PIP:

Admin@Win7 ~
$ easy_install pip

Finally we install Django:

Admin@Win7 ~
$ pip install django

Congratulations, if you've gotten this far then you've successfully setup a Django development environment with virtualenv.

If you have any questions then drop me a line in the comment box below.

— Andrew

Next entry

Previous entry

Related entries

Similar entries


  1. cmemery
    cmemery on 02/16/2011 10:20 p.m.

    Like your blog post, setting up something similar myself. Hate the captcha/math thing; it loses what you tried to post if you get it wrong (I entered the text I saw rather than the solution to the problem the first time). Wouldn't be so bad if it cached the submission and repopulated the form fields. Anyway, thanks for the post :)

  2. Totok
    Totok on 05/04/2011 9:39 p.m.

    Great post! Thanks.

  3. clay
    clay on 05/12/2011 9:41 p.m.

    This was a big help. Many thanks.


Pingbacks are open.

Post your comment

Site theme originally by