Part 1 - Installing software

For this part, I loosely followed this guide on Installing Pip, Virtualenv & VirtualenvWrapper on OS X.

Install pip

I already had pip installed. However, if I were to install it, I would need: sudo easy_install pip

Install virtualenv

I intalled virtualenv with this command: sudo pip install virtualenv

Install virtualenvwrapper

Next, I installed virtualenvwrapper as so: sudo pip install virtualenvwrapper

Then, I had to go to my home directory cd $HOME and create a directory for the virtualenvs mkdir .virtualenvs.

For my shell to load the virtualenvwrapper script, I needed to add this to my bash file. So, I opened my bash profile file nano .bash_profile and added this line source /usr/local/bin/virtualenvwrapper.sh.

To verify the installation, I reinitiated the terminal and typed mkv and hit Tab. It should autocomplete to mkvirtualenv.

Part 2 - Setting up environment

For this part, I loosely followed this guide on Tips for using Pip + Virtualenv + Virtualenvwrapper.

Export current environment requirements

I already had installed dependencies via pip, so to export them I ran the following command pip freeze > requirements.txt.

Create a virtualenv

Next, I created my virtualenv from my project directory with the dependencies I exported mkvirtualenv my_virtual_env -a `pwd` -r requirements.txt.

Installing Django in the virtualenv

Since I am now working in a virtualenv, I have to install Django in here sudo pip install Django.

Part 3 - Begin Django project

Now, I’m ready to start my Django project!

It is recommended to have a virtualenv per Django project since the dependencies may defer. You could also have multiple virtualenvs for a project if you need different Python versions, for example.

About Giselle Zeno
I'm a Computer Science PhD student at Purdue and an avid coder. more