Step-by-Step: Installing Django, page 3
Posted Aug. 11, 2008 at 8:39 a.m. by wheaties
Learn how to get started with Django on Windows, Linux, and Mac OS X.
Installing Django
Once you have Python and have verified that you have version 2.3 or later, you are ready to install Django. Currently, the latest stable release is 0.96.1, but this is grossly out-dated. Django 1.0 will be released on September 2nd 2008, so the "unstable" copy of Django is pretty close to what 1.0 will have to offer. There are some incredibly useful improvements in the unstable version that I don't think I could do without anymore, so that's what I'll talk about installing here.
First, you need to have a subversion client. On Windows, the most popular one is called TortoiseSVN. On Mac OS X, I have played with a few, but I think Versions is a pretty decent one. Linux also has several to choose from, but if you're using Linux, you're probably going to use the command line anyway (right?).
For brevity, I will just use the subversion commands necessary to accomplish this task (instead of discussing all GUI interfaces to subversion).
The exact location that Django should be installed differs from system to system, but here are some guidelines for typical setups:
- Windows: C:\Python25\Lib\site-packages
- Linux: /usr/lib/python2.5/site-packages
- Mac OS X: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages
If you want a definite location, run the following command:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
Once you know that location, go there in your command prompt or terminal session. Then execute this command svn co http://code.djangoproject.com/svn/django/trunk/django django. You will see loads of output, showing all of the files that you are downloading as you install Django.
As soon as that process completes, you should run python -c "import django" to make sure everything worked properly. If the command doesn't display an ImportError, you're good. Otherwise, you need to try again.
Getting Access to Django Scripts...
Once you can successfully import django, you might want to make sure you can run the django-admin.py script that comes with Django.
...On Windows
This process is very similar to what we did with the PYTHONPATH environment variable earlier.
- Open your System Properties again
- Go to the Advanced tab
- Click the Environment Variables button
- Find your PATH environment variable (either for your user or system-wide)
- Make sure that the variable value contains something like C:\Python25\Lib\site-packages\django\bin
- Save any changes
- Open a fresh command prompt
- Try to run django-admin.py. If you're successful, you're ready to get started with Django. Otherwise, you need to fix your path to django/bin or just call the django-admin.py script using an absolute path when needed.
...On Mac OS X
You can run a command similar to this:
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/bin/django-admin.py /usr/local/bin
...On Linux
If you have "root" privileges on your Linux system, you can execute a command like:
sudo ln -s /usr/lib/python2.5/site-packages/django/bin/django-admin.py /usr/local/bin
If you don't have "root" privileges, you can setup your own /usr/local/bin:
mkdir ~/bin
Make sure your ~/.bash_rc contains something like:
export PATH=$HOME/bin:$PATH
Then update your current session with any changes you made to ~/.bash_rc by running this command:
source ~/.bash_rc
And that should do it! Now you should be ready to get started with Django.
Feel free to leave a comment if you're having problems installing Django. Good luck!
Check out Installing Django on Shared Hosting.
Comments
Post a Comment
This article is closed for comments.

Thanks for the cool walk through, and the one on one help, other than the SVN nonsense that I was struggling with it all worked like a charm