Distribute, Distribute/Zip hack, Distribute/distutils, Distribute/setuptools, Project, virtualenv

virtualenv Doc

Installation Debian

# apt-get install virtualenv

Installation via pip see virtualenv Doc.

Create enviroment

$ virtualenv [ENVIROMENT]

Create python3 enviroment

$ virtualenv -p python3 [ENVIROMENT]


$ source bin/activate


$ deactivate

Installing an application/module for testing purposes

Be sure your application uses a shebang like #!/usr/bin/env python. This ensures with an activated virtualenv the application will use the modules within the virtualenv paths. By deactivating the virtualenv the system wide paths will be used instead. With a #!/usr/bin/python shebang always the system wide installed modules are used which isn't the expected behaviour for an activated virtualenv.

While virtualenv is activated you don't need root permissions to install the python application/module.

$ source [ENVIROMENT]/bin/activate
$ python install

or by using pip:

$ source [ENVIROMENT]/bin/activate
$ pip install [APPLICATION]

Note that virtualenv is no virtual machine! This means by example if an application stores its data within the users home directory (os.environ['HOME']) this will be the same path whether virtualenv is activated or not.

After testing the application/module deactivate virtualenv and install it system wide:

$ deactivate

Now you must be root:

# python install

or via pip:

# pip install [APPLICATION]
Last modified 6 weeks ago Last modified on Mar 14, 2019, 10:22:00 AM