pymatgen-core
raw JSON → 2026.4.16 verified Fri May 01 auth: no python
Python Materials Genomics (pymatgen) core library for materials analysis, providing object representations for structures, molecules, and crystals. Current version 2026.4.16, released April 2026. Active development with monthly releases, compatible with Python >= 3.11. This package is a refactored subset of the original pymatgen, focusing on core data structures and basic I/O.
pip install pymatgen-core Common errors
error ImportError: cannot import name 'Structure' from 'pymatgen' (unknown location) ↓
cause pymatgen-core moved core classes to pymatgen.core subpackage.
fix
Use 'from pymatgen.core import Structure' instead.
error ModuleNotFoundError: No module named 'pymatgen.io.vasp' ↓
cause VASP I/O is not part of pymatgen-core; it's in the full pymatgen package.
fix
Install pymatgen (the full package) via 'pip install pymatgen' and import from 'pymatgen.io.vasp'.
error AttributeError: 'Structure' object has no attribute 'get_sorted_structure' ↓
cause Some methods may not be available in pymatgen-core if they were moved to other modules.
fix
Check the pymatgen-core documentation for available methods. Use pymatgen (full) if the method is missing.
Warnings
breaking pymatgen-core is a refactored subset of pymatgen. Many modules (e.g., analysis, io.vasp, electronic_structure) are not included; they remain in the full pymatgen package. Code that imports from pymatgen.core will break if it expects all functionality of pymatgen. ↓
fix Install pymatgen (the full package) if you need advanced features. Use pymatgen-core only for core data structures and basic I/O. Adjust imports to use pymatgen.core subpackage.
gotcha Some classes that were previously at the top-level pymatgen (e.g., Structure, Molecule) are now inside pymatgen.core. Direct imports from pymatgen will fail with ImportError or AttributeError. ↓
fix Change 'from pymatgen import Structure' to 'from pymatgen.core import Structure'.
deprecated The original pymatgen package may eventually be superseded by pymatgen-core. Users should monitor migration guides for future breaking changes. ↓
fix Stay updated with release notes. Consider using pymatgen-core for new projects if you only need core features.
Imports
- Structure wrong
from pymatgen import Structurecorrectfrom pymatgen.core import Structure - Molecule wrong
from pymatgen import Moleculecorrectfrom pymatgen.core import Molecule - Lattice wrong
from pymatgen import Latticecorrectfrom pymatgen.core import Lattice - Element wrong
from pymatgen import Elementcorrectfrom pymatgen.core import Element
Quickstart
from pymatgen.core import Structure, Lattice, Element
# Create a simple silicon diamond cubic structure
lattice = Lattice.cubic(5.431) # lattice constant in Angstrom
species = [Element("Si")] * 8
coords = [
[0, 0, 0],
[0.25, 0.25, 0.25],
[0.5, 0.5, 0],
[0.5, 0, 0.5],
[0, 0.5, 0.5],
[0.75, 0.75, 0.25],
[0.75, 0.25, 0.75],
[0.25, 0.75, 0.75]
]
structure = Structure(lattice, species, coords, coords_are_cartesian=False)
print(structure)
print(f"Volume: {structure.volume:.2f} ų")