For reference, the Numpy dependency probably could be worked around, but if Biopython itself requires a C compiler then you're not going to be able to (easily) get that going. For the sake of completeness I tried building a virtualenv with --system-site-packages
and then inside that doing pip install -I --no-deps biopython
and indeed it definitely still requires a C compiler. Bummer.
Since we already have a compiled version installed on the system, however, we can probably engage in some underhanded hackery to clone it. Try the following - first, create a virtualenv:
source virtualenvwrapper.sh
mkvirtualenv --system-site-packages biopython-local
You can use a different name from biopython-local
, but if you do then replace it in all of the commands below. Whatever name you use has to be a valid filename (and I strongly suggest sticking to letters, digits, -
and _
).
At this point you should see your prompt has the prefix (biopython-local)
to show you're inside your virtualenv, like this:
(biopython-local)10:41 ~ $
If you don't see this on your prompt, type:
If you still don't see it, STOP and ask here for advice because something's gone wrong (probably I made a typo in the instructions or something). By the way, I strongly suggest putting that first line (source virtualenvwrapper.sh
) in your .bashrc
otherwise you'll have to do it each login to enable access to the mkvirtualenv
and workon
commands.
Once we've created your virtualenv, we can manually copy the Biopython packages into it. Paste each of these commands in turn, pressing enter after each one:
cp -r /usr/local/lib/python2.7/site-packages/Bio ~/.virtualenvs/biopython-local/lib/python2.7/site-packages
cp -r /usr/local/lib/python2.7/site-packages/BioSQL ~/.virtualenvs/biopython-local/lib/python2.7/site-packages
cp -r /usr/local/lib/python2.7/site-packages/biopython-1.61-py2.7.egg-info/ ~/.virtualenvs/biopython-local/lib/python2.7/site-packages
After you do this, you should now be able to run up an interactive Python interpreter and confirm that you're importing the version of Biopython which you just copied:
(biopython-local)10:41 ~ $ python
Python 2.7.3 (default, Apr 22 2013, 12:32:55)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Bio
>>> print Bio.__file__
/home/neville/virtualenvs/biopython-local/lib/python2.7/site-packages/Bio/__init__.pyc
Note that the file is in your home directory. If you see the file is in fact in /usr/local/lib
somewhere then stop and ask because again, something's gone wrong.
At this point you should be able to modify the files for your local Biopython install to your heart's content - they should be located under these directories:
/home/neville/virtualenvs/biopython-local/lib/python2.7/site-packages/Bio
/home/neville/virtualenvs/biopython-local/lib/python2.7/site-packages/BioSQL
If you want to edit your virtualenv, just run deactivate
. When you want to get back inside it (after logging off, for example) then just run workon biopython-local
.
Finally, you need to also activate your virtualenv when your web app runs, otherwise it'll still see the system-installed Biopython. This tutorial covers the steps required to run the latest version of Django in a web app which is very close to what you need to do, but you'll need to make some appropriate changes. Essentially the start of your web app will look like this:
activate_this = '/home/neville/.virtualenvs/biopython-local/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
As you can see, it's just a case of running the script activate_this.py
which will have been created for you in your virtualenv.
As an aside, you can read more about virtualenv on it's web page - it's an extremely useful tool for creating isolated environments so you can control which versions of libraries you use and also make your own local changes like this.
Do let us know how you get on.