Pádraig Kitterick

Windows + Django +svn = Ugh!

Posted in Code, Python, Web by Pádraig on March 19th, 2006

After reinstalling windows recently I once again had to battle with the process of installing Django on Windows XP. All I remember about the last time was several hours of googling (if that isn’t a word ti aught to be) and cursing at the *nix-centric installation notes on the django website. So this time I decided to take notes so that I could put together a semi-coherent guide to installing Django on windows for development purposes. Here goes…

As I am interested in keeping up with the latest features of Django I’ll be using svn to grab the latest snapshot. To use any the official releases instead just download and extract them into a folder of your choice and skip forward to step 3.

Step 1 - Set up your Python paths
First, check that the main Python folder and the scripts folder are in your system path. To do this, right-click on My Computer, and select Properties -> Advanced -> Environment Variables. Edit the ‘PATH’ variable and add your Python and Python/scripts paths if necessary. Close any open command-line windows and open a new one (Start->Run->cmd.exe). If you can run ‘python’ and see a python prompt then you’re ready to continue.

While you are editing your environment variables I would also suggest adding ‘.PY’ to the PATHEXT variable. This allows you to run any python script without having to add the ‘.py’ extension to the end of the command, e.g. ‘django-admin.py’ becomes just ‘django-admin’

Step 2 - Get Django
First, make sure you have python and svn installed and in your PATH so that you can run them from any folder. Then run the following:

svn co http://code.djangoproject.com/svn/django/trunk/ django

This will check out the latest development code and place it in a folder called ‘django’. Using svn means that we can update the code to the latest version at anytime by moving into the ‘django’ folder and running

svn update

Nice, eh?!

Step 3 - Install setuptools
Move to the folder where you checked out django and run:

python ez-setup.py

This will install setuptools which is needed to easily install Django in your current Python installation.

Step 4 - Install Django
Finally we want to link Django to the current Python install (version 2.4 is recommended here). To do this, once again make sure you are in the django folder, and then execute:

python setup.py develop

This will put the django-admin.py script into your Python scripts folder and will create a link to your new django source code install in a .pth file in site-packages (the usual location to install Python modules, etc.). This is the magic bit which allows you to check out django in any location on your PC that you want and be able to access it as a Python module without any messy configuration files.

And that’s it! You should now be able to run ‘django-admin.py’ without any errors.

Leave a Reply