Question about importing Composition in pymatgen 2026.5.4

Dear Materials Project team,

Thank you for providing this platform for discussions.

Recently, I encountered an error when running the following import:

from pymatgen.core.composition import Composition

The error message is:

ModuleNotFoundError: No module named 'pymatgen.core.composition'

The pymatgen version I am using is 2026.5.4.

I could not find any update or documentation related to changes in this import path. Could you please let me know whether the import path for Composition has changed in recent versions, or if there is another recommended way to import it?

Thank you very much for your help.

Best regards,
Xue

Moved this to the pymatgen category. pymatgen is now two separate packages, pymatgen-core and pymatgen. If you recently updated pymatgen, you may need to pip uninstall pymatgen-core && pip install pymatgen-core to avoid issues with how the namespaces are set up

2 Likes