Skip to content

Instantly share code, notes, and snippets.

@j127
Last active January 15, 2016 19:21
Show Gist options
  • Save j127/7c635703479be25fc84b to your computer and use it in GitHub Desktop.
Save j127/7c635703479be25fc84b to your computer and use it in GitHub Desktop.
Virtualenv and Virtualenvwrapper on Ubuntu (or similar)

How to install virtualenvwrapper on Ubuntu

Run these commands in the terminal. The $ means your terminal prompt.

$ sudo apt-get update
$ sudo apt-get install python-pip
$ sudo pip install virtualenv
$ sudo pip install virtualenvwrapper

Open up your .bashrc file. Example: gedit ~/.bashrc. If you use zsh, then edit ~/.zshrc instead. Put these lines at the bottom:

alias mkve3='mkvirtualenv --python=`which python3`'
export WORKON_HOME=~/Envs
source /usr/local/bin/virtualenvwrapper.sh

Save the file and type: source ~/.bashrc. Now it's installed and ready.

  • Create a Python 2 virtualenv: mkvirtualenv my_venv
  • Create a Python 3 virtualenv: mkve3 my_other_venv
  • Deactivate a virtualenv: deactivate
  • Work on an existing virtualenv: workon my_virtualenv_name (tab-completion should work)

Once a virtualenv is activated, you can install packages with pip: pip install requests.

You don't need to use sudo.

Your Python packages will be located at ~/Envs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment