From charlesreid1

No edit summary
No edit summary
Line 3: Line 3:
This can be obtained from here: http://pypi.python.org/pypi/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.
=Installing=


Install it by running:
==How It Works==
 
To install virtualenv, you will pick a prefix (an installation directory), and virtualenv will create its own <code>bin/</code> and <code>lib/</code> directories, along with its own python binary. This binary wraps the already-installed python binary, wherever it is on the system, but does so in a way that strips out any information about paths, libraries, packages, modules, etc.
 
It also wraps the system's versions of easy_install and pip, so you can also install modules and packages in the usual way.
 
This gives you a clean, sterile version of Python, and the tools needed to install any and all modules and libraries in a stand-alone version of Python. This keeps you from having to deal with issues with an existing system Python, and it also allows you to shuffle and change things around without ever changing (breaking) the system python.
 
==Instructions==
 
Download the virtualenv tarball and untar it to the source directory. Change to this directory and run:


<pre>
<pre>
$ python setup.py install --prefix=${HOME}/pkg/virtualenv
$ python setup.py build
$ mkdir -p $HOME/pkg/virtualenv/lib/python2.7/site-packages/
$ export PYTHONPATH=$HOME/pkg/virtualenv/lib/python2.7/site-packages:$PYTHONPATH
$ python setup.py install --prefix=$HOME/pkg/virtualenv
</pre>
</pre>


or wherever you want to install it.
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>


[[Category:Python]]
[[Category:Python]]

Revision as of 19:13, 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

Installing

How It Works

To install virtualenv, you will pick a prefix (an installation directory), and virtualenv will create its own bin/ and lib/ directories, along with its own python binary. This binary wraps the already-installed python binary, wherever it is on the system, but does so in a way that strips out any information about paths, libraries, packages, modules, etc.

It also wraps the system's versions of easy_install and pip, so you can also install modules and packages in the usual way.

This gives you a clean, sterile version of Python, and the tools needed to install any and all modules and libraries in a stand-alone version of Python. This keeps you from having to deal with issues with an existing system Python, and it also allows you to shuffle and change things around without ever changing (breaking) the system python.

Instructions

Download the virtualenv tarball and untar it to the source directory. Change to this directory and run:

$ python setup.py build
$ mkdir -p $HOME/pkg/virtualenv/lib/python2.7/site-packages/
$ export PYTHONPATH=$HOME/pkg/virtualenv/lib/python2.7/site-packages:$PYTHONPATH
$ python setup.py install --prefix=$HOME/pkg/virtualenv

or wherever you want to install it.