Skip to content

"No module named constraint" #2050

Done

Description

@rubber-duck-debug

I've tried installing rdkit from both pypi, but also from source (what I'm using below) and they both result in the same error. Any thoughts?

I'm using:

openff-toolkit @ git+https://github.com/openforcefield/openff-toolkit.git@0.16.8
python -c "from openff.toolkit.topology import Molecule; smi = \"CC\"; molecule = Molecule.from_smiles(smi); molecule.generate_conformers(n_conformers=1)"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/nick/uv-venvs/test_env/lib/python3.11/site-packages/openff/toolkit/topology/molecule.py", line 2323, in generate_conformers
    return toolkit_registry.call(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nick/uv-venvs/test_env/lib/python3.11/site-packages/openff/toolkit/utils/toolkit_registry.py", line 280, in call
    raise ValueError(msg)
ValueError: No registered toolkits can provide the capability "generate_conformers" for args "(Molecule with name '' with bad SMILES and Hill formula 'C2H6',)" and kwargs "{'n_conformers': 1, 'rms_cutoff': None, 'clear_existing': True, 'make_carboxylic_acids_cis': True}"
Available toolkits are: [ToolkitWrapper around The RDKit version 2025.09.1pre, ToolkitWrapper around Built-in Toolkit version None]
 ToolkitWrapper around The RDKit version 2025.09.1pre <class 'ModuleNotFoundError'> : No module named 'constraint'

Activity

  1. j-wags commented on Apr 30, 2025

    @j-wags
    Member

    Thanks for the concise example, but I'm unable to reproduce. Here are my steps:

    micromamba create -n temp openff-toolkit -c conda-forge
    micromamba activate temp
    micromamba remove --force rdkit
    pip install --force rdkit
    python -c "from openff.toolkit.topology import Molecule; smi = \"CC\"; molecule = Molecule.from_smiles(smi); molecule.generate_conformers(n_conformers=1)"
    

    It's likely you're encountering missing deps since you're using an installation route other than conda. We don't officially support installation via pip, since some of our deps historically haven't been available there, we want to minimize our maintenance surface area, and our advisory board wasn't interested in us spending resources to support it. However, you may be able to make a working pip-only build by installing pip equivalents of the packages from from our testing conda environment - many (if not all) of the non-OpenFF packages are available from pypi.

    If you do manage to get it working, I'm sure other folks might find it useful - Please post here if you do!

  2. rubber-duck-debug commented on Apr 30, 2025

    @rubber-duck-debug
    Author

    Hey j-wags,

    many thanks for the comment. I'm using uv/pip because it's easier to work with in a HPC environment that uses ARM/GH200s with spack integration, and many of the packages in my environment require building from source.

    I got it to work by additionally installing:

    uv pip install python-constraint #import constraint
    uv pip install git+https://github.com/openforcefield/openff-forcefields.git #smirnoff 2.0
    
    python -c "from openff.toolkit.topology import Molecule; smi = \"CC\"; molecule = Molecule.from_smiles(smi); molecule.generate_conformers(n_conformers=1)"
    

    Now passes without error. I'll write more complete from-scratch installation instructions when I get some more time later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions