Step 1: Install Cygwin & Python
Most of the installation is just clicking next, and accepting the defaults:
Choose your closest Mirror. We like Internode!
This is where we stop clicking next and select our packages.
We'll probably need to install a Subversion client, so also select that:
wget will make installing the Django stuff easier:
gcc and gcc++ will be needed later to compile some of the Python libraries (eg PIL):
No *nix environment should be without vi, an evil and arcane text editor:
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:
The installer will automatically pull in all the necessary dependencies:
Creating an icon is probably a good idea:
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):
The installation is now complete. Double click on the icon on the desktop, and then type python
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 http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6 .egg#md5=bfa92100bd772d5a213eedd356d64086 --2011-01-11 12:22:59-- http://pypi.python.org/packages/2.6/s/setuptools/setupt ools-0.6c11-py2.6.egg Resolving pypi.python.org (pypi.python.org)... 220.127.116.11, 2001:888:2000:d::a 8 Connecting to pypi.python.org (pypi.python.org)|18.104.22.168|: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 3447]
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
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/virtualenvwrapper.sh" >> ~/.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 (myproject) Admin@Win7 ~ $ cd myproject
Now is probably a good time to install PIP:
(myproject) Admin@Win7 ~ $ easy_install pip
Finally we install Django:
(myproject) 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.