Library / SDK
materialsproject/pymatgen avatar
materialsproject/pymatgen

Pymatgen for materials analysis and electronic structure data

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.

2,002 stars976 forksPythonNOASSERTION

At a glance

What is it?
Pymatgen is a Python library for representing materials data, reading scientific file formats and performing higher-level analyses. It suits research workflows that need more than basic structure handling, while `pymatgen-core` provides a smaller dependency boundary.
Who is it for?
Adopt the full `pymatgen` package when a project needs phase diagrams, Pourbaix diagrams, defects, surfaces, interfaces, electronic structure analysis, command-line applications or external integrations. Use `pymatgen-core` when the requirement is limited to core representations and file I/O.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 3 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Pymatgen's materials data model and intended users

Pymatgen addresses a recurring problem in computational materials science: analysis programs need a shared way to represent an element, lattice, periodic structure, molecule or composition before they can read calculation output, calculate properties or exchange data. The library defines these objects and places analysis modules around them. It is relevant to materials researchers, electronic structure practitioners and Python engineers who need a common interface across formats such as CIF, XYZ, VASP, ABINIT and Gaussian.

The audience includes users of the Materials Project. The project metadata describes Pymatgen as the analysis code powering Materials Project, while the README points users to official documentation, issue discussions and community support. It is a library rather than a standalone modeling application. It organizes data and analyses, but the repository does not position it as a replacement for the electronic structure programs that generate input and output files.

The package requires Python 3.11 or later. Its metadata lists Python 3.11 through 3.14 and gives the project an operating-system-independent classification. This is a substantial scientific Python package rather than a small utility library. A project should account for its Python version and dependency footprint, then select either the complete package or the narrower core distribution.

Core objects, pymatgen-core and higher-level analysis

The architecture has an important installation split. Core objects such as `Element`, `Site`, `Molecule`, `Structure`, `Composition` and `Lattice`, together with file I/O for major electronic structure codes, live in `pymatgen-core`. The full `pymatgen` package depends on the core distribution and adds analyses, applications and external integrations. The README states that these core classes remain available through the familiar `pymatgen.core` namespace, which can reduce import-path changes in code written for the combined package.

The `pymatgen.analysis` namespace contains tools for phase diagrams, Pourbaix diagrams, reaction analysis, local environments, surfaces, interfaces, defects, magnetism, piezoelectricity and elasticity. Electronic structure analysis includes density of states and band structure. Thermodynamic and reaction data have representations under `pymatgen.entries`, while external services are exposed through `pymatgen.ext`. The `pymatgen.apps` and `pymatgen.cli` namespaces provide end-user applications and command-line access.

This split affects adoption. A script that only loads structures or molecules can avoid the full package's higher-level dependencies. A workflow that computes defect models or electronic structure summaries needs the full distribution. The repository includes `examples/` and `test-files/`, but the README directs users to the official documentation for tutorials instead of presenting a complete first-analysis walkthrough.

Installing Pymatgen and choosing the package boundary

The README identifies the Python Package Index release as the latest stable release and gives `pip` as the installation route. Install the complete package when the project needs its analyses, applications and external integrations. This dependency also installs `pymatgen-core`.

bash
pip install pymatgen

The README points to the official documentation for tutorials and examples. It also links `matgenb`, which contains example Jupyter notebooks, and `computron/pymatgen_tutorials`, a separate tutorial resource. Since the README excerpt does not include a minimal script, the traceable first step after installation is to choose one of those examples for the data type or analysis used by the project.

For an installation containing only core objects and file I/O, use `pymatgen-core` directly. The README describes this as a much lighter install.

bash
pip install pymatgen-core

The lighter package does not include the higher-level analysis modules. It is a deliberate dependency reduction, not a feature-equivalent installation. Some functionality requires additional setup, and the README specifically identifies POTCAR generation as an example. A completed base installation therefore does not confirm that every VASP-related feature is ready to use.

File readers, analysis flow and external integrations

Pymatgen connects common representations with downstream calculations. A conceptual workflow begins with a structure or molecule object, passes it through format-specific I/O or an electronic structure integration, and then sends the resulting object into an analysis module. The README does not provide commands or parser-specific configuration for each format, so those details should come from the relevant official documentation rather than be inferred from the package names.

The README names VASP, ABINIT, CIF, Gaussian and XYZ among supported formats, as well as many other formats. Electronic structure analyses can produce density of states and band structure information. Thermodynamic data objects support calculations involving entries and reactions. Local environment, surface, interface and defect modules operate on materials representations rather than replacing those representations with unrelated formats.

External integrations form a separate layer under `pymatgen.ext`. The README names the Materials Project REST API and other materials databases. It does not document credentials, environment variables or integration setup. Code that depends on an external database should therefore keep remote access separate from local parsing and treat service configuration as its own operational concern.

Performance claims and practical constraints

The README says that many core numerical methods are vectorized with `numpy` and `scipy`, and that Pymatgen includes a system for periodic boundary conditions. Those statements make the library relevant to coordinate manipulation and materials calculations. They do not establish performance for a particular workload. The README publishes no benchmark, memory target or timing result for phase diagrams, defect calculations or structure parsing, so a project should evaluate its own representative structures and analyses.

Compatibility extends beyond the package version. Project metadata requires Python 3.11 or later and lists several supported Python versions, while analyses may depend on external scientific tools, calculation outputs or optional integrations. POTCAR generation explicitly requires additional setup. The README also states that GitHub Actions runs continuous integration over a unit-test suite. That supports the existence of automated checks, but it does not mean every optional external program or service is configured in a user's environment.

Package width is the clearest limitation for a narrow application. The full `pymatgen` install is heavier than `pymatgen-core`. Choosing the complete distribution for a script that only parses structures can introduce dependencies the script never uses. Conversely, choosing `pymatgen-core` for defects, thermodynamics or electronic structure analysis leaves the script without required modules. The correct boundary follows from the analysis classes and I/O the application actually calls.

Maintenance signals, licensing and upgrade work

The repository is not archived, and its last push was on 2026-10-15. Listed releases include `v2026.9.24`, `v2026.9.23` and `v2026.5.4`. The README points to GitHub releases, `docs/CHANGES.md` and commit history for change information at different levels of detail. These are the relevant places to inspect before an upgrade because the repository contains a large Python package and declares a versioned dependency on `pymatgen-core`.

Licensing requires direct inspection. Repository metadata describes the license as other because GitHub cannot classify the custom terms, while `pyproject.toml` declares `MIT` and lists `LICENSE` through `license-files`. This article does not interpret the legal effect of those files. Projects should read the repository's `LICENSE` file and confirm that its terms match their intended use and distribution.

Upgrade cost depends on scope. A core-only project can review changes involving `pymatgen-core`. A project using analyses, CLI features or external integrations must inspect the full package dependency graph and release notes. The repository includes `uv.lock`, tests and development configuration, indicating a developed build and test environment. Those files do not remove the need to check release notes for API changes or altered file-format behavior that could affect an existing script.

Where Pymatgen fits against narrower alternatives

For local scripts that only represent lattices, compositions, structures and molecules or read a small set of files, `pymatgen-core` is the more direct alternative to installing all of Pymatgen. The difference is package scope: the core distribution contains the data objects and major file I/O, while the full package adds analysis, applications and external integrations. A general-purpose text parser is not equivalent, because Pymatgen models the physical and chemical concepts used by materials calculations.

For users who want computations outside Python, the Python API may also be the wrong interface. The README mentions `pymatgen.cli` and `pymatgen.apps`, but it does not provide a complete command catalog in the installation section. A team should not assume every feature has a documented CLI equivalent. Likewise, Materials Project REST access is an integration feature, not a replacement for every local calculation or database workflow.

The practical comparison is therefore dependency and capability based. Use the core package when structure representation and I/O dominate. Use the full package when a documented analysis, application or external integration is required. Pymatgen is the wrong choice when the required operation has no corresponding module in its documented namespaces, or when an optional calculator still requires substantial separate setup.

Editorial conclusion

Adopt the full `pymatgen` package when a project needs phase diagrams, Pourbaix diagrams, defects, surfaces, interfaces, electronic structure analysis, command-line applications or external integrations. Use `pymatgen-core` when the requirement is limited to core representations and file I/O. Before adoption, verify Python 3.11 or later, check whether the selected analysis needs extra setup, and read the repository `LICENSE` file because the repository metadata uses a custom classification while `pyproject.toml` declares MIT.

Frequently asked questions

What is Pymatgen used for?

Pymatgen is used for materials analysis in Python. It represents structures and molecules, reads files from major electronic structure codes, and provides analyses including phase diagrams, defects, surfaces, interfaces, elasticity and electronic structure summaries.

How do I install Pymatgen?

The README gives `pip install pymatgen` for the full package, including analyses, applications and external integrations. For core objects and file I/O only, it gives `pip install pymatgen-core` as the lighter option.

What is the difference between Pymatgen and pymatgen-core?

`pymatgen-core` contains core data objects and file I/O for major electronic structure codes. The full `pymatgen` package depends on it and adds higher-level analyses, applications and external integrations.

Which Python version does Pymatgen require?

The project metadata specifies `requires-python = ">=3.11"` and lists Python 3.11 through 3.14.

Does installing Pymatgen configure every external materials tool?

No. The README says some functionality, including POTCAR generation, requires additional setup. External integrations and optional analysis tools may therefore need configuration beyond the base installation.

Official sources

  1. Issues
  2. materialsproject/pymatgen on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/materialsproject-pymatgen.svg)](https://hysenlabs.com/projects/materialsproject-pymatgen)

Was this useful?