In this tutorial, we’ll cover just the basics of setting up a virtualenv for your FireWorks installation. Virtualenv allows you to isolate your FireWorks installation from your other Python installations. This is often done when there are conflicts (e.g., two codes require different versions of Python), and sometimes done just for cleanliness or to host separate testing and production environments. Another reason to use virtualenv is when you don’t have permission to access the global Python “site-packages” directory, e.g. on a shared machine like a supercomputing center.
Introduction to virtualenv¶
Your virtualenv is stored inside a user-specified directory on your system. That directory will contain the Python 2.7.3 executable needed for FireWorks as well as all dependencies for the FireWorks code. When you activate your virtualenv, your “normal” Python executable will be bypassed in favor of the one in this directory. In addition, your normal “site packages” directory that contains your external Python libraries will be bypassed in favor of the one you set up in your virtualenv. Finally, your “pip” and “easy_install” will be bypassed so that they install packages to your virtualenv. When you deactivate your virtualenv, things will return back to their usual state.
Setting up virtualenv¶
First, download and install virtualenv with pip:
pip install virtualenv
You may need administrator privileges, i.e.
sudo pip install virtualenv. At supercomputing centers, virtualenv might be available as a module and loadable using
module load virtualenv. Contact your system administrator if you have questions about this.
Create a directory that will contain your virtualenv files (Python exe and libraries for FireWorks). We’ll call this
FW_envbut you can name it whatever you like:
Set up a clean virtual env into this directory:
virtualenv --no-site-packages FW_env
Activate your virtual environment:
Your bash prompt should change to show what environment you’re in after you’ve activated the virtualenv. You can now continue with the FireWorks installation instructions in your virtual environment.
If you ever want to deactivate and go back to normal, just type