Virtualenv

From aldeid
Jump to: navigation, search

Description

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

virtualenv

Description

Incomplete.png
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.png
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/[email protected]" && workon "[email protected]"
}
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

blog comments powered by Disqus

Keywords: virtualenv virtualenvwrapper python development