As described in the downloading
instructions, we provide three ways for you to get the libSBML Python
language interface easily without having to configure and build libSBML
manually from sources. You can use (1) PyPI, the Python Package Index; (2)
binary packages for use with standard Linux installation tools such as
yum
and apt-get
; or (3) executable installers for
Windows.
If you downloaded one of the ready-to-use Python installers for libSBML, you should not need to do anything more: you should be able to access libSBML from your Python interpreter by importing it like any other Python module. In other words, the following should work:
from libsbml import *
PYTHONPATH
environment variable. To cope with the fact that different Unix-like systems
(including Mac OS X) use different conventions for where they
install Python modules, the following is a general-purpose setting for
PYTHONPATH
. Here, DIR
represents the value of the --prefix=
DIR/usr/local
) and
version is the version of your copy of
Python (this might be, e.g., 2.7
). If you use sh-based
shells such as Bash, put this in your shell's initialization file or execute
it in your shell before starting the Python interpreter:
PYSITE=DIR/lib/version/site-packages PYDIST=DIR/lib/version/dist-packages export PYTHONPATH=$PYTHONPATH:$PYSITE:$PYSITE/libsbml:$PYDIST:$PYDIST/libsbmlIf you use csh-based shells instead of Bash or other sh-based shells, then the appropriate syntax is the following:
set PYSITE = DIR/lib/version/site-packages set PYDIST = DIR/lib/version/dist-packages setenv PYTHONPATH ${PYTHONPATH}:${PYSITE}:${PYSITE}/libsbml:${PYDIST}:${PYDIST}/libsbml
Once the PYTHONPATH
variable has been set, you should be
able to start the Python interpreter and type the following command to
import the libSBML package for Python:
from libsbml import *
If Python produces an import error or a failure in linking a new module, it
probably means that PYTHONPATH
has not been set correctly.
It may also mean that the read/write permissions of the installed library
files or a directory in the hierarchy containing them are such that you are
not allowed to access the files. In that case, please consult your systems
administrator or (if you have administrator priviledges) reset the
permissions yourself.