Installing virtualenv

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. Always use qlogin to first get a terminal on a node in the cluster.

  1. Set up directories
    • Create a bin directory in your home directory via mkdir ~/bin
    • Edit ~/.bash_profile and add $HOME/bin to that PATH variable
      (eg. PATH=$HOME/bin:$PATH)
    • Log out and back in for the change to take effect
  2. Download virtualenv from Python
    • Extract the downloaded tarball into bin
    • Create a symlink to the virtualenv script like the following:
      ln -s virtualenv-x.x.x/ virtualenv
  3. (optional) If using Biopython, first load it via module load biopython
  4. Create an environment via virtualenv --system-site-packages /path/to/ENV
    (or just use ENV and it will create an environment within the current working directory)
  5. Load the new environment via source /path/to/ENV/bin/activate

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 to run module load biopython first. If you want this done automaticly, you can add the command to ~/.bash_profile.