From charlesreid1

(Redirected page to Python#Virtual Python: virtualenv)
 
No edit summary
Line 1: Line 1:
#REDIRECT [[Python#Virtual_Python:_virtualenv]]
If you don't want to deal with the difficulties of installing a system version of Python, or you don't have the permissions to do so, you have another option: install a virtual version of Python, called virtualenv.
 
This can be obtained from here: http://pypi.python.org/pypi/virtualenv
 
Essentially you install it to a prefix, where it will create a /prefix/bin/ and /prefix/lib/ directory.  Then a python binary is put into /prefix/bin/, and it wraps the system python and so can load all relevant libraries, etc., but can also load libraries in /prefix/lib/ so that you can extend Python, without ever touching the system version of Python.
 
Install it by running:
 
<pre>
$ python setup.py install --prefix=${HOME}/pkg/virtualenv
</pre>
 
or wherever you want to install it.
 
Then, whenever you want to install a Python package and make it loadable by virtualenv, you just append the same <code>--prefix</code> to the end of setup.py:
 
<pre>
$ cd /path/to/package
$ python setup.py install --prefix=${HOME}/pkg/virtualenv
</pre>

Revision as of 19:02, 20 November 2013

If you don't want to deal with the difficulties of installing a system version of Python, or you don't have the permissions to do so, you have another option: install a virtual version of Python, called virtualenv.

This can be obtained from here: http://pypi.python.org/pypi/virtualenv

Essentially you install it to a prefix, where it will create a /prefix/bin/ and /prefix/lib/ directory. Then a python binary is put into /prefix/bin/, and it wraps the system python and so can load all relevant libraries, etc., but can also load libraries in /prefix/lib/ so that you can extend Python, without ever touching the system version of Python.

Install it by running:

$ python setup.py install --prefix=${HOME}/pkg/virtualenv

or wherever you want to install it.

Then, whenever you want to install a Python package and make it loadable by virtualenv, you just append the same --prefix to the end of setup.py:

$ cd /path/to/package
$ python setup.py install --prefix=${HOME}/pkg/virtualenv