Installing libsbml with python support on Debian wheezy

Installing libSBML on Debian begins the same way as on Ubuntu. First follow the instructions in this post.

After compiling and installing, libsbml on Ubuntu should be working.

In Debian, if you try to import libsbml, you get the following error:
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/libsbml/__init__.py", line 27, in
_libsbml = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/libsbml/__init__.py", line 23, in swig_import_helper
_mod = imp.load_module('_libsbml', fp, pathname, description)
ImportError: libsbml.so.5: cannot open shared object file: No such file or directory

To get it working you have to set PYTHONPATH variable:
In commandline:
export PYTHONPATH=/usr/local/lib/python2.7/dist-packages/libsbml

It is also possible to modify environment variable from within python code:
import sys
sys.path.append('/usr/local/lib64/python2.7/site-packages/libsbml')

You can get and set environment variables via os.environ:
import os
os.environ['PYTHONPATH'] = '/usr/local/lib/python2.7/dist-packages/libsbml'

But since your interpreter already runs, this will have no effect.

Published by

MartinsM

Martins M.