OpenBabel (unofficial wheel distribution)
raw JSON → 3.1.1.23 verified Mon Apr 27 auth: no python
Unofficial PyPI distribution of OpenBabel (version 3.1.1.23), providing prebuilt wheels for Python ≥3.8. OpenBabel is a chemical toolbox for interconverting chemical file formats, molecular modeling, and cheminformatics. This package is useful when building from source is impractical.
pip install openbabel-wheel Common errors
error ImportError: No module named openbabel ↓
cause The package is not installed or is installed but named differently.
fix
Run 'pip install openbabel-wheel'. Then use 'import openbabel' (not 'import openbabel-wheel').
error AttributeError: module 'openbabel' has no attribute 'OBMol' ↓
cause You imported the openbabel module but forgot to import its submodule 'openbabel' (the C++ bindings).
fix
Use 'from openbabel import openbabel' then 'openbabel.OBMol()'.
Warnings
gotcha The openbabel package is the top-level library. The familiar 'pybel' module is NOT included in this wheel. You must use openbabel.pybel or direct openbabel API. ↓
fix Use 'from openbabel import pybel' (if pybel is needed) or directly use openbabel.OBMol etc.
deprecated This wheel packages a newer OpenBabel version (3.1.1+) which has breaking changes from the old 'openbabel' package (e.g., removal of certain convenience functions). The official OpenBabel bindings have moved to 'openbabel.openbabel' for the underlying C++ bindings. ↓
fix Check migration guides from OpenBabel 2.x to 3.x. Use 'openbabel.openbabel' for low-level functions.
gotcha On some systems, the wheel may conflict with a system-installed OpenBabel. Ensure no other OpenBabel library is being loaded inadvertently. ↓
fix Run 'import openbabel; print(openbabel.__file__)' to verify which module is loaded.
Imports
- openbabel wrong
import openbabel as obcorrectimport openbabel - OBMol wrong
from openbabel import OBmolcorrectfrom openbabel import openbabel mol = openbabel.OBMol()
Quickstart
import openbabel
# Create a molecule
mol = openbabel.OBMol()
# Build from SMILES
conv = openbabel.OBConversion()
conv.SetInAndOutFormats('smi', 'mol')
conv.ReadString(mol, 'CCO')
print('Formula:', mol.GetFormula())