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
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()'.
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.

Basic usage: create an OBMol, read SMILES, print formula.

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())