Samudra Neelam Bhuyan


How to setup a Django / python development env on Windows

Install Python

  1. Download and install the latest Python installer from here
  2. Change the %PATH% variable to add the path to the python.exe file

Install VirtualEnv

  1. Download virtualenv from here
  2. Install virtualenv with the command:
  3. Activate the new virtual env by :
  4. Add the paths to the ‘Scripts’ and ‘Lib’ folders in %PATH%. It should be of the form:

Install Django

  1. Make sure your virtual env is activated
  2. Install Django by: pip install django
  3. In case of the following error:
    File "E:\Python27\YOUR_ENVIRONMENT\Scripts\", line 2, in
    from django.core import management
    ImportError: No module named django.core
    • Check the folder permissions of the “django” folder inside “YOUR_ENVIRONMENT\Lib\site-packages“. Remove any read-only permission settings.
    • Use this command to use the “correct” Python (the one inside the virtual environment) to open the .py files:
      ftype Python.File="E:\Python27\YOUR_ENVIRONMENT\Scripts\python.exe" "%1" %*
  4. Run “ startproject YOUR_PROJECTNAME”. If this works, that means Django is installed fine.

Install Postgresql

  1. Download Postgresql from here and install it.
  2. Modify YOUR_PROJECT\, and change the lines to include your DB config:
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
            'NAME': 'YOUR_DATABASE_NAME',                      # Or path to database file if using sqlite3.
            'USER': 'YOUR_USER_OR_ROLE_NAME',                      # Not used with sqlite3.
            'PASSWORD': 'YOUR_PASSWORD',                  # Not used with sqlite3.
            'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
            'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
  3. Run
    python runserver

    This will probably fail… with an error like this:

    ImportError: No module named psycopg2.extensions

    Don’t worry.. this seems to be normal :) Psycopg2 does not work with VirtualEnv.

  4. Download THE CORRECT VERSION OF Psycopg2. You CANNOT install this file. You have to extract the files inside the exe file with an utility like 7Zip. You will get a folder called “psycopg2″ (and possibly a file called “psycopg2-2.4.5-py2.7.egg-info”). Copy these into

Happy coding!