virtualenv is a great way of running different Python instances in isolation from your default Python setup. Python based software often needs specific python versions and specific modules to be loaded. virtualenv allows separate instances of Python to be created on your workstation that have different custom setups.
My example is based upon installing MACS (peak caller), in particular because there are different versions that I need to run depending on the project I am working on. I am also using the Fedora Linux OS, so the installation of virtualenv will probably differ depending on your OS.
1. Install virtualenv to your OS (in this case Fedora 19)
sudo yum install python-virtualenv.noarch
2. Create a new virtualenv environment
This create a directory called
macs2_20130731 in your current directory.
3. Install Python packages needed by the program (in this case MACS)
macs2_20130731/bin/pip install numpy
pip is a Python package repository.
4. Install MACS itself from a TAR archive downloaded from the github repository
macs2_20130731/bin/pip install MACS2-188.8.131.5230731.tar.gz
5. Running the program (in this case MACS)
This method allow different instances of MACS that can be easily run in isolation from other versions. Of note I have also been able to run my own instance of GALAXY using this method.
that's a good point. one can usually just use
Interesting package. I guess I've never looked, so could you give a couple examples of packages that need different python versions? I'd imagine that this would be more common with things being 2.x or 3.x specific, but perhaps I've just not paid enough attention!
I have not personally used virtualenv to enable different versions of Python, but it appears to be a possible function. Python 3 is reported to be quite different from Python 2, so could be a useful function. My prime use of virtualenv is to allow multiple versions of the same software to be run on the same system.
@Devon, it's more than python2/3. If you have one package that relies on an old version of numpy, and one on a new version, virtualenv makes that simple. In addition, it makes it more straighttforward (though still not trivial) to do repeatable work with a well-defined list of python dependencies.
Thanks (to both you and Ian ), I can definitely foresee making use of this in the future!