#1 Le 19/09/2011, à 16:25
- petertosh
[RESOLU] Lier Python à LibSBML
Bonjour,
Je viens vous poser une colle, plutôt compliquée je pense
J'ai besoin de lier une librairie scientifique (LibSBML) à Python. L'installation de LibSBML est ok mais je n'arrive pas à appeler cette librairie dans Python.
Je dois lancer dans le prompt Python
from libsbml import *
Il me ressort l'erreur suivante:
No module named libsbml
Sur la documentation je me retrouve avec l'information suivante:
First, note that by default, libSBML only builds the C and C++ APIs. To build the Python API as well, libSBML has to be configured with the --with-python flag as described in the installation instructions.
Once that is done, and libSBML has been installed on your system, then Python needs just one more thing to be informed where to find the libSBML package: it needs the environment variable named PYTHONPATH to be set. On Unix-based systems at least, if DIR is the value of the --prefix=DIR option given during configuration of libSBML and version is the version of your copy of Python, then the value of PYTHONPATH needs to be set as follows:
export PYTHONPATH=DIR/lib/version/site-packages
for sh-based shells such as Bash, or
setenv PYTHONPATH DIR/lib/version/site-packages
for csh-based shells. In other words, the PYTHONPATH environment variable needs to be set to the site-packages directory path where the libSBML library has been installed. Please see the section titled "Files installed by libSBML, and their locations" elsewhere in this manual for more information about the files installed for 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 almost certainly means that the environment variables have 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.
Je ne comprends pas grand chose, est-ce que vous pourriez m'éclairer à lier python et cette fameuse librairie sans laquelle je ne peux pas utiliser mon logiciel?
Un énorme merci à vous
Dernière modification par petertosh (Le 20/09/2011, à 10:23)
Hors ligne
#2 Le 19/09/2011, à 17:37
- petertosh
Re : [RESOLU] Lier Python à LibSBML
Je progresse,
J'ai recomplilé le prrogramme à la main (libsbml) avec : ./ configure --with-python
Iil semble bien s'installer mais voila ce que je j'obtiens avec la commande suivante:
from libsbml import*
In [1]: from libsbml import*
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)/home/tonio/<ipython console> in <module>()
/usr/local/lib/python2.6/dist-packages/libsbml/__init__.py in <module>()
24 fp.close()
25 return _mod
---> 26 _libsbml = swig_import_helper()
27 del swig_import_helper
28 else:/usr/local/lib/python2.6/dist-packages/libsbml/__init__.py in swig_import_helper()
20 if fp is not None:
21 try:
---> 22 _mod = imp.load_module('_libsbml', fp, pathname, description)
23 finally:
24 fp.close()ImportError: libsbml.so.5: cannot open shared object file: No such file or directory
Une idée pour m'aider à avancer un peu plus?
Merci à vous
Dernière modification par petertosh (Le 19/09/2011, à 17:40)
Hors ligne
#3 Le 20/09/2011, à 10:21
- petertosh
Re : [RESOLU] Lier Python à LibSBML
Bon j'ai cherché et j'y suis arrivé.
Mon soucis est que j'avais installer les librairies à partir d'un .deb
J'ai tout supprimé, télécherger la fichiers en .tar.gz et installé à la main.
./ configure --with-python
make && make install
La librairies est bien liée à Python par la suite.
Hors ligne