I am trying to use openbabel within python in macOS BigSur, I have installed openbabel and py310-openbabel through macports without any problem, however when I run python3.10 I get the following when importing openbabel:
>>> from openbabel import openbabel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openbabel/__init__.py", line 3, in <module>
from . import openbabel
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openbabel/openbabel.py", line 19, in <module>
from . import _openbabel
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openbabel/_openbabel.cpython-310-darwin.so, 2): Symbol not found: __ZN9OpenBabel9aromtyperE
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openbabel/_openbabel.cpython-310-darwin.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openbabel/_openbabel.cpython-310-darwin.so
The otool output seems correct:
otool -L /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openbabel/_openbabel.cpython-310-darwin.so
/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openbabel/_openbabel.cpython-310-darwin.so:
/opt/local/lib/libopenbabel.7.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 905.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)
I have also tried to install openbabel with pip after removing the one installed with macports, which gave me exactly the same error on import within python. The command I used to install it with pip was:
sudo pip-3.10 install --global-option=build_ext --global-option="-I/opt/local/include/openbabel3/" --global-option="-L/opt/local/lib/" openbabel
Any ideas on how to solve this?