Install Virtualenv And Virtualenvwrapper On Ubuntu
Install virtualenv and virtualenvwrapper on Ubuntu
Akbar S. Ahmed | Feb 10, 2015

Step-by-step instructions

virtualenv is an absolute must if you develop with Python. In simple terms, virtualenv creates a folder that stores a private copy of python, pip, and other Python packages. You can then enable this private folder while working a project. By using the virtual environment, you can use different versions of Python and Python packages on a per project basis.

In this post we will step through setting up virtualenv and virtualenvwrapper on Ubuntu Linux.

Step-by-step instructions

Open a terminal and install the following packages.

sudo apt-get install python-pip python-dev build-essential

sudo pip install virtualenv virtualenvwrapper

sudo pip install --upgrade pip

Setup virtualenvwrapper in ~/.bashrc.

# Create a backup of your .bashrc file
cp ~/.bashrc ~/.bashrc-org

# Be careful with this command
printf '\n%s\n%s\n%s' '# virtualenv' 'export WORKON_HOME=~/virtualenvs' \
'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc

Enable the virtual environment.

source ~/.bashrc

mkdir -p $WORKON_HOME

mkvirtualenv api

# Exit the 'api' virtual environment
deactivate

Tips on using virtualenv

To enable the api virtual environment, run the following command:

workon api

To deactivate the api virtual environment, run the following command:

deactivate

That’s it. You now have a virtual environment setup for your Python development.




Subscribe to our newsletter

Contact Information

ABOUT EXPONENTIAL.IO

We specialize in helping professional developers, like you, expand your skill set. Our courses are focused on enabling you to learn everything necessary to use a new technology in a live, production application.

LOCATION

All courses are made with love in
Palo Alto, CA.

Subscribe to our newsletter