How to python virtualenv

Install pip

sudo apt-get install python-pip

Install virtualenv

sudo pip install virtualenv

Create a dir to store your virtualenvs (I use ~/.virtualenvs)

mkdir ~/.virtualenvs

At this point you are all set to use virtualenv with the standard commands. However, I prefer to use the extra commands included in virtualenvwrapper. Lets set that up.

Install virtualenvwrapper

sudo pip install virtualenvwrapper

Set WORKON_HOME to your virtualenv dir

export WORKON_HOME=~/.virtualenvs

Add virtualenvwrapper.sh to .bashrc

Add this line to the end of ~/.bashrc so that the virtualenvwrapper commands are loaded.

. /usr/local/bin/virtualenvwrapper.sh

Exit and re-open your shell, or reload .bashrc with the command . .bashrc and you’re ready to go.

Create a new virtualenv

mkvirtualenv myawesomeproject

to exit your new virtualenv, use deactivate.

Switch between enviornments with workon

To load or switch between virtualenvs, use the workon command:

workon myawesomeproject

Associate virtualenv with project folder:

setvirtualenvproject

You can read more about virtualenv here and virtualenvwrapper here. You might also want to look at this very similar (and probably better) python guide post.

Вы можете отслеживать комментарии к этой записи с помощью RSS 2.0. Комментарии и эхо-тестирование не разрешены.

Обсуждение закрыто.