Currently ''virtualenv'' only supports Python up to version 2.7. If you really need virtual environment on Python 3, check out the [http://bitbucket.org/brandon/virtualenv3 virtualenv3] project on Bitbucket.

+

''virtualenv'' supports Python 2.5+ and Python 3.x.

===Installation===

===Installation===

−

Simply install python-virtualenv from the community repository and you're done:

+

Simply install from the community repository:

# pacman -S python2-virtualenv

# pacman -S python2-virtualenv

+

or

+

# pacman -S python-virtualenv

===Basic Usage===

===Basic Usage===

Line 37:

Line 38:

== Virtualenvwrapper ==

== Virtualenvwrapper ==

−

''virtualenvwrapper'' allows more natural command line interaction with your virtualenvs by exposing several useful commands to create, activate and remove virtualenvs. Like ''virtualenv'', this package does not currently support Python 3.x.

+

''virtualenvwrapper'' allows more natural command line interaction with your virtualenvs by exposing several useful commands to create, activate and remove virtualenvs. This package is a wrapper for both {{Pkg|python-virtualenv}} and {{Pkg|python2-virtualenv}}.

−

===Installation===

===Installation===

−

[[pacman|Install]] the {{Pkg|python-virtualenvwrapper}} package from the [[Official Repositories|official repositories]]. If you have not installed {{Pkg|python-virtualenv}} yet, {{Pkg|python-virtualenvwrapper}} will be installed now as a dependency.

+

[[pacman|Install]] the {{Pkg|python-virtualenvwrapper}} package from the [[Official Repositories|official repositories]].

Now add the following lines to your {{ic|~/.bashrc}}:

Now add the following lines to your {{ic|~/.bashrc}}:

Revision as of 03:46, 16 January 2013

virtualenv is a Python tool written by Ian Bicking and used to create isolated environments for Python in which you can install packages without interfering with the other virtualenvs nor with the system Python's packages.
The present article covers the installation of the virtualenv package and its companion command line utility virtualenvwrapper designed by Doug Hellmann to (greatly) improve your work flow. A quick how-to to help you to begin working inside virtual environment is then provided.

Contents

Virtual Environments at a glance

virtualenv is a tool designated to address the problem of dealing with packages' dependencies while maintaining different versions that suit projects' needs. For example, if you work on two Django web sites, say one that needs Django 1.2 while the other needs the good old 0.96. You have no way to keep both versions if you install them into /usr/lib/python2/site-packages . Thanks to virtualenv it's possible, by creating two isolated environments, to have the two development environment to play along nicely.

vitualenvwrapper takes virtualenv a step further by providing convenient commands you can invoke from your favorite console.

Virtualenv

virtualenv supports Python 2.5+ and Python 3.x.

Installation

Simply install from the community repository:

# pacman -S python2-virtualenv

or

# pacman -S python-virtualenv

Basic Usage

An extended tutorial on how use virtualenv for sandboxing can be found here.

The typical use case is:

Create a folder for the new virtualenv:

$ mkdir -p ~/.virtualenvs/my_env

Create the virtualenv:

$ virtualenv2 ~/.virtualenvs/my_env

Activate the virtualenv:

$ source ~/.virtualenvs/my_env/bin/activate

Install some package inside the virtualenv (say, Django):

(my_env)$ pip install django

Do your things

Leave the virtualenv:

(my_env)$ deactivate

Virtualenvwrapper

virtualenvwrapper allows more natural command line interaction with your virtualenvs by exposing several useful commands to create, activate and remove virtualenvs. This package is a wrapper for both python-virtualenv and python2-virtualenv.