{"library":"pymatgen","title":"Pymatgen: Python Materials Genomics","description":"Pymatgen (Python Materials Genomics) is a robust materials analysis code that defines core object representations for crystal structures, molecules, and electronic structure data. It powers the Materials Project and offers extensive tools for materials design, data analysis, and high-throughput computations. The current version is 2026.3.23, and it maintains a rapid release cadence, often with monthly or bi-monthly updates.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install pymatgen"],"cli":{"name":"pmg","version":"usage: pmg [-h] {config,analyze,query,plot,structure,view,diff,potcar} ..."}},"imports":["from pymatgen.core import Structure","from pymatgen.core import Lattice","from pymatgen.core import Molecule","from pymatgen.ext.matproj import MPRester","from pymatgen.io.vasp import Vasprun","from pymatgen.io.vasp.inputs import Kpoints"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom pymatgen.core import Structure, Lattice, Species\nfrom pymatgen.ext.matproj import MPRester\n\n# 1. Create a simple crystal structure (e.g., BCC iron)\nlattice = Lattice.cubic(2.86)\nspecies = [Species(\"Fe\")]\ncoords = [[0, 0, 0]]\nstructure = Structure(lattice, species, coords)\nprint(f\"Created structure: {structure.formula} with {structure.num_sites} sites.\")\n\n# 2. Use MPRester to fetch data (requires API key)\n# Get your API key from materialsproject.org after logging in\n# Set it as an environment variable 'MP_API_KEY'\napi_key = os.environ.get(\"MP_API_KEY\", \"\")\n\nif api_key:\n    try:\n        with MPRester(api_key) as mpr:\n            # Fetch entries for a chemical system, e.g., Li-Fe-O\n            entries = mpr.get_entries(\"Li-Fe-O\", inc_structure=True, property_data=[\"band_gap\"])\n            print(f\"Found {len(entries)} entries for Li-Fe-O.\")\n            if entries:\n                first_entry = entries[0]\n                print(f\"First entry formula: {first_entry.formula_pretty}\")\n                if \"band_gap\" in first_entry.data:\n                    print(f\"Band gap: {first_entry.data['band_gap']} eV\")\n    except Exception as e:\n        print(f\"Error fetching data from Materials Project: {e}\")\n        print(\"Ensure your MP_API_KEY is valid and has network access.\")\nelse:\n    print(\"MP_API_KEY environment variable not found. Skipping MPRester example.\")","lang":"python","description":"This quickstart demonstrates how to create a basic `Structure` object and interact with the Materials Project database using `MPRester`. An `MP_API_KEY` environment variable is required for `MPRester` functionality.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"2024.8.9","pypi_latest":"2026.5.4","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":28.3,"avg_import_s":2.07,"wheel_type":"sdist"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pymatgen","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pymatgen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":26.9,"import_time_s":1.41,"mem_mb":37.4,"disk_size":"568M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pymatgen","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pymatgen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":26.9,"import_time_s":2.24,"mem_mb":37.2,"disk_size":"647M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pymatgen","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pymatgen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":28.8,"import_time_s":2.28,"mem_mb":36.1,"disk_size":"615M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pymatgen","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pymatgen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":28.5,"import_time_s":2.1,"mem_mb":36.1,"disk_size":"611M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pymatgen","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pymatgen","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":30.5,"import_time_s":2.32,"mem_mb":56.3,"disk_size":"577M"}]}}