pythondjangoopenbabelpybel

"IndexError: list index out of range" on "import pybel"


I'm working on a web app django, when I install openbabel and try to import pybel i've got an error

I'm using a venv that was activate when I did all this commands

I install openbabel like this:

sudo apt-get install python-openbabel

I also tried :

sudo apt-get install openbabel libopenbabel-dev swig

Then I did :

pip install openbabel

after that, I've tried to import pybel (after importing openbabel)

This is actuall result :

>>> import pybel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/etudiant/QuChemPedIA/QuChemPedIAProject/venv/lib/python3.5/site-packages/pybel.py", line 94, in <module>
    descs = _getpluginnames("descriptors")
  File "/home/etudiant/QuChemPedIA/QuChemPedIAProject/venv/lib/python3.5/site-packages/pybel.py", line 84, in _getpluginnames
    return [x.split()[0] for x in plugins]
  File "/home/etudiant/QuChemPedIA/QuChemPedIAProject/venv/lib/python3.5/site-packages/pybel.py", line 84, in <listcomp>
    return [x.split()[0] for x in plugins]
IndexError: list index out of range

Any help please?


Solution

  • As @Manu mathew said, this is a bug, but not in Python's openbabel package but rather in the openbabel C library that it wraps (provided by the openbabel apt package).

    The bug is fixed in version openbabel/2.3.2+dfsg-3 that for your Ubuntu Xenial (judging by your Python version) is not available.

    So you need to upgrade your distro. The fix is available since Bionic but for best results, upgrade to the latest distro release (see below for explanation).


    Beside that,

    But since in this case, there's no apt-get version of bindings available, you have to install the bindings from PyPI. In this case, you'd better have the C library version that corresponds to the bindings' version -- i.e. probably the latest -- since that combination was clearly extensively tested.