Installing and Running Django Tutorial on Anaconda Python

So I want to do some more fluffy web based stuff with python, and, ultimately, mongodb. I’m doing things properly and starting with the Django tutorial. I’ve already installed Anaconda to provide me with a  full python 2.7 and the key data analysis packages pre-installed. The Anaconda windows installer works perfectly.

An aside, but the ipython notebook is brilliant. Runs a local webserver on your machine with the python command line running. You can record everything you do, download copies and send to others, inline graph generation, etc. It’s lovely.

Fire up a DOS command line.

So I started by checking to see if Django was already installed:

python -c "import django; print(django.get_version())"

It wasn’t. easy_install and pip often don’t work directly from the command line, with either python 2.7 installed manually  or with anaconda, so I went for the safe option that seems to work everytime and:

where python
C:\Users\me\AppData\Local\Continuum\Anaconda\python.exe
cd C:\Users\me\AppData\Local\Continuum\Anaconda\Scripts
pip install Django

That installed Django for me fine. I checked again to see what version was installed:

python -c "import django; print(django.get_version())"
1.6.2

So now I need the Django Tutorial for this version. Note that if your version of Django/python is different to mine, you will need to select the right Documentation version. You can do that with the control atthe bottom RHS of the tutorial page.

Next, it wants me to create the project. I have to cd to my source folder and run a command. That command blows up:

C:\me\projects\reporting\incubator>django-admin.py startproject mysite
Traceback (most recent call last):
File "C:\Users\me\AppData\Local\Continuum\Anaconda\Scripts\django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core

Sad Face. But let’s work around those pesky path issues like we did with pip:

C:\me\projects\reporting\incubator>python C:\Users\me\AppData\Local\Continuum\Anaconda\Scripts\django-admin.py startproject mysite

Success. Happy Face. Mental note made. Continuing with the tutorial.

I didn’t have the sqlite3 shell installed, so downloaded it from sqlite.org.