Python Environment for Ubuntu: Part 1

We're going to go through a few steps to get a nice development environment for working with Python (and Django) on Ubuntu.

We're going to be using pip to install and manage packages, but first we need easy_install, which comes with the setuptools package. To install setuptools (and easy_install), run the following:

sudo apt-get install python-setuptools

To ensure this has worked, run the following command which should return the version number of easy_install.

easy_install --version

To install pip run:

sudo easy_install pip

Again to verify that pip was installed correctly, check its version.

pip --version

Next we'll see pip to install virtualenv and virtuenvwrapper:

sudo pip install virtualenv
sudo pip install virtualenvwrapper

Next, we're going to set virtualenv to store our virtual environments in our home folder to keep things tidy:

mkdir ~/.virtualenvs
echo "export WORKON_HOME=~/.virtualenvs" >> ~/.bashrc

Setup bash to work with virtualenv (this should be the path to your

echo "source /usr/local/bin/" >> ~/.bashrc
echo "export PIP_VIRTUALENV_BASE=~/.virtualenvs" >> ~/.bashrc

Finally, one more recommended step. We're creating an alias which will cause mkvirtualenv to not use site packages and to use distribute (instead of setuptools).

echo "alias mkvirtualenv='mkvirtualenv --no-site-packages --distribute'" >> ~/.bashrc

To reload our new bash settings without restarting our shell, run the following (or just open a new terminal window), otherwise you will get 'command not found' errors when running virtualenv:

source ~/.bashrc

That's it! You can now begin creating and using virtual environments in Part 2.