DevOps Buzz
Search…
⌃K

Virtualenv

Setup a virtualenv using virtualenvwrapper

Install virtualenvwrapper and create your first virtualenv

Install virtualenvwrapper
sudo pip3 install virtualenvwrapper
Edit your bashrc file and add te following content.
~/.bashrc
export WORKON_HOME="$HOME/virtualenvs"
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
Then run.
source ~/.bashrc
Create a virtualenv.
mkvirtualenv env1

Setup .bashrc config

Add the following lines in your ~/.bashrc file.
~/.bashrc
# Virtualenvs
export WORKON_HOME=~/virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

Useful commands

Change virtualenv

workon yourvirtualenvname

"Logout" from a virtualenv

deactivate

"cd" to your virtualenv automatically

Run this only one time.
workon yourvirtualenvname
echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate

References