virtualenv is a python tool that allows you to build a local python environment where you can test code and even install python packages without installing them into the system python packages. To setup this tool in the context of the cluster takes a few steps. Note, always use qlogin to first get a terminal on a node in the cluster.
- Setup directories
Create a 'bin' directory in your home directory via 'mkdir ~/bin'
Edit ~/.bash_profile and add $HOME/bin to that PATH variable, for example:
Logout and back in for the change to take effect
- Download virtualenv from pypi
Extract the downloaded tarball into bin
Create a symlink to the virtualenv script like so:
ln -s virtualenv-x.x.x/virtualenv.py virtualenv
- (Optional) If using Biopython, first load it via 'module load biopython'
- Create an environment via 'virtualenv --system-site-packages /path/to/ENV'
Or just use 'ENV' and it will create an environment right within the current working directory
- Load the new environment via 'source /path/to/ENV/bin/activate'
Now you should see your environment name on the prompt in the terminal and when you run python or install python packages, it will be within the context of your new python environment.
Note: This creates an environment that also makes available any packages already installed on the system. If you want to create a blank environment, omit '--system-site-packages'
Note: If using Biopython, also make sure you run 'module load biopython' first. If you want this done automaticly, you can add the command to ~/.bash_profile