Virtualenv

From aldeid
Jump to navigation Jump to search

Description

INCOMPLETE SECTION OR ARTICLE
This section/article is being written and is therefore not complete.
Thank you for your comprehension.

virtualenv

Description

INCOMPLETE SECTION OR ARTICLE
This section/article is being written and is therefore not complete.
Thank you for your comprehension.

Installation

$ sudo pip install virtualenv

virtualenvwrapper

Description

INCOMPLETE SECTION OR ARTICLE
This section/article is being written and is therefore not complete.
Thank you for your comprehension.

Installation

Install:

$ sudo pip install virtualenvwrapper

Then add following lines to your ~/.bashrc file:

# Python virtualenv
export WORKON_HOME=/data/development/virtualenvs
mkdir -p $WORKON_HOME
source /usr/bin/virtualenvwrapper.sh

A convenient trick is to also add the following lines to your ~/.bashrc so that the workon command automatically jumps to the directory corresponding to the selected virtual environment:

# workon alias to jump to directory (if your development sources are in /data/development/)
function workon_cd {
    cd "/data/development/$@" && workon "$@"
}
alias workon="workon_cd"

Create a virtual environment

To create a virtual environment with virtualenvwrapper, do as follows:

$ mkvirtualenv name 

If you want to bind it with a specific version of python (e.g. python 2.7), do as follows:

$ mkvirtualenv -p /usr/bin/python2.7 name 

Commands

List virtual environments
$ lsvirtualenv
Enter a virtual environment
$ workon ENVNAME 
Quit a virtual environment
$ deactivate
Remove a virtual env
$ rmvirtualenv ENVNAME 


Comments

Keywords: virtualenv virtualenvwrapper python development