Setting up your environment this way avoids most errors on this page.
| Practice | What happens if you skip it |
|---|---|
| In the conda environment you use, run conda install -c conda-forge openbabel to get the program and the Python bindings together. | pip compiles the bindings locally and fails with SWIG failed. |
| With Open Babel 3.x, import with from openbabel import pybel. | The 2.x style import pybel fails with No module named pybel. |
| Do not mix libopenbabel from apt with Python bindings from pip. | Mismatched versions or build options cause missing features or missing shared libraries. |
| Install libraries that depend on Open Babel, such as pymatgen and molgrid, in the same environment as Open Babel. | Those libraries cannot find the Open Babel Python bindings from their own environment. |
| Do not build Open Babel from source. | You have to handle CMake, SWIG, Eigen and Python paths yourself, and missing any one leaves features or bindings out. |
Troubleshooting by error message
Find your exact error message. Each entry gives the cause, the fix, and what may come up after the fix.
ModuleNotFoundError: No module named 'openbabel'
Cause: The Open Babel Python bindings are installed for another Python, or only the obabel command line program is installed.
Fix: Activate the environment you use and run conda install -c conda-forge openbabel; confirm with python -c "import sys; print(sys.executable)" that your script runs this environment's Python.
What may come next: For a source install under /usr/local, put PYTHONPATH in ~/.bashrc; an export in one terminal is lost in the next.
ModuleNotFoundError: No module named 'pybel'
Cause: Since Open Babel 3.0, pybel lives inside the openbabel package, so the 2.x import pybel no longer works.
Fix: Use from openbabel import pybel; for the low-level API use from openbabel import openbabel.
What may come next: Old scripts written for Open Babel 2.x may need other calls changed as well.
ImportError: cannot import name 'pybel' from 'openbabel' (unknown location)
Cause: The source build of Open Babel did not produce the Python bindings, so Python only finds an empty openbabel folder.
Fix: Use conda install -c conda-forge openbabel instead; if you must build from source, rebuild with CMake options -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON.
Error: SWIG failed. Is Open Babel installed? (usually preceded by Unable to find 'openbabel/babelconfig.h')
Cause: pip install openbabel compiles the Python bindings locally with SWIG but cannot find the Open Babel headers and libraries.
Fix: Use conda install -c conda-forge openbabel instead; if the Open Babel library is already installed, point to it with python setup.py build_ext -I/usr/local/include/openbabel3 -L/usr/local/lib and install again.
What may come next: Bindings built by pip must match the local Open Babel library version and need rebuilding after the library is upgraded.
ImportError: libopenbabel.so.3: cannot open shared object file: No such file or directory
Cause: The Open Babel shared library is not on the library search path, typical for source builds under /usr/local.
Fix: Add the folder containing libopenbabel.so to LD_LIBRARY_PATH, for example export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH.
AttributeError: module 'openbabel' has no attribute 'OBConformerSearch'
Cause: The Open Babel library installed with apt on Ubuntu was built without Eigen, which drops conformer search and other features.
Fix: Use Open Babel from conda-forge; if you build it yourself, install Eigen first and then build the library and the bindings.
RuntimeError: BabelMolAdaptor requires openbabel to be installed with Python bindings.
Cause: pymatgen cannot find Open Babel 3.0+ Python bindings in its own environment.
Fix: Run conda install -c conda-forge openbabel in the environment where pymatgen is installed.
Scientify is a cloud computer with research software installed and AI agents such as Codex and Claude Code built in. Describe what you need in one sentence, for example "convert these SMILES to 3D structures, optimize them with the MMFF94 force field and export an SDF file", and the agent uses the preinstalled Open Babel to do the format conversion and structure processing, with no software to install and no code to write.
Compared with installing more on your own computer, the cloud computer already has Open Babel 3.2.1 with its Python bindings, plus RDKit, OpenMM and PDBFixer in the same environment, so there is no SWIG, shared library or import path to deal with, and runs continue after you close your laptop.
The cloud computer comes with more computing power: CPU and GPU clusters can be called on demand for large-scale scientific computing. Compute is billed by the minutes you actually use, so nothing is wasted.
- Cloud computer
- 4 vCPU · 8 GB
- Top configuration, for data processing and small to medium jobs
- Callable GPU
- 96 GB VRAM
- Up to an RTX PRO 6000 per GPU; H800 80 GB and up to 8 × A10G also available
- Callable CPU
- 224 cores · 3 TB
- Largest spec, for large parallel computations
References
- Open Babel: install Python bindings — pip install, LD_LIBRARY_PATH and the 3.x import
- openbabel-discuss: No module named openbabel — PYTHONPATH set in only one terminal
- openbabel-discuss: SWIG failed — babelconfig.h not found and build_ext paths
- openbabel-discuss: cannot import name pybel — Source builds without bindings and BabelMolAdaptor
- openbabel-discuss: No module named pybel — pybel import error on Windows
- Launchpad: OBConformerSearch — apt build lacks Eigen; fixed by rebuilding
- Gist: Open Babel Python bindings on a cluster — Pointing pip at include and library folders