Creating a virtual environment for working with EPD

  • Download Gist

At my institute I'm faced with lots of differently configured workstations, to which I cannot install software. A consistent Python install is not present, so I need to create an environment for my calculations myself, within my $HOME directory.

For what I write, I'm assuming that EPD is installed in the directory ~/lib/epd-7.1-1-x86_64.

First, I install pip into the EPD dir (EPD doesn't ship with pip as of 7.1):

andreas@antares:~/lib/epd-7.1-1-x86_64$ bin/easy_install pip

Next, I install virtualenv:

andreas@antares:~/lib/epd-7.1-1-x86_64$ bin/pip install virtualenv
andreas@antares:~/lib/epd-7.1-1-x86_64$ bin/pip install virtualenvwrapper

Then I can create the virtualenv in which I'll be working. In my case, I called it pydoas:

andreas@antares:~/lib/epd-7.1-1-x86_64$ bin/virtualenv --no-site-packages ~/.virtualenvs/pydoas
andreas@antares:~$ source ~/bin/

I need to make sure some environment variables are set correctly. Therefore, I create the script ~/.virtualenvs/pydoas/bin/postactivate:

# This hook is run after this virtualenv is activated.
export PATH=/home/andreas/.virtualenvs/pydoas/bin:/home/andreas/lib/epd-7.1-1-x86_64/bin:/usr/lib/gmt/bin:$PATH
export PYTHONPATH=/home/andreas/.virtualenvs/pydoas/lib/python2.7/site-packages:/home/andreas/lib/epd-7.1-1-x86_64/lib/python2.7/site-packages
export LD_LIBRARY_PATH=/home/andreas/.virtualenvs/pydoas/lib:/home/andreas/lib/epd-7.1-1-x86_64/lib

Now, you can switch into that environment with the simple command

andreas@antares:~$ workon pydoas

Inside this environment, you can for example install pandas:

(pydoas)andreas@antares:~$ pip install pandas

Everything you install with pip easy_install while in the virtual environment will go to the ~/.virtualenvs/pydoas/bin/postactivate directory, so won't clutter up your EPD install.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.