Installing and using virtualenvwrapper on ubuntu

Virtualenvwrapper is wrapper on virtualenv tool. This is useful when we are working with different versions of python and want to keep site packages seperate for each project.

Here are quick step by step instructions on installing and using virtualenvwrapper. I have done it on Ubuntu 16.04 but steps should be same for other ubuntu versions  –

1. Make sure pip is installed

sudo apt-get install python-pip

2. Install virtual env on ubuntu 16.04

sudo pip install virtualenvwrapper

3. Configure the path to virtualenv , projects and scripts to be installed. For this add the below lines to ~/.bashrc file

sudo nano ~/.bashrc

Paste below code at the bottom of file

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

cntrl + O => to save the file
cntrl + X for closing the file

Now reload the bashrc file with below command on terminal –

run source ~/.bashrc

4. Create envirnment with default python executable

mkvirtualenv <envname>

5. Create environment with specific python executable

mkvirtualenv <envname> -p /usr/bin/python3.5

6. Activating the envirnment

workon <envname>

7. List all envirnments

workon

OR

lsvirtualenv

8. remove envirnemnt

rmvirtualenv <envname>

For more information you can check virtualenvwrapper documentation or virtualenv.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s