I am trying to retrieve band structures using the official example code from the documentation:
from mp_api.client import MPRester
from emmet.core.electronic_structure import BSPathType
with MPRester(API_KEY) as mpr:
bs_sc = mpr.get_bandstructure_by_material_id("mp-149")
However, this currently fails in my environment with a Pydantic ValidationError related to missing equivalent_labels fields:
ValidationError: bandstructure.setyawan_curtarolo.equivalent_labels
Field required
I then tried using use_document_model=False and retrieving the band structure via task_id, but get_bandstructure_from_task_id() attempts to access an old S3 path such as:
s3://materialsproject-parsed/bandstructures/1057384.json.gz
and returns:
MPRestError: No object found
My environment is:
mp-api version: 0.46.1
Python: 3.11
Could you please let me know what the currently recommended code is for retrieving a full pymatgen BandStructureSymmLine object for a material such as mp-149 or SiO2? Is the official example outdated, or is there a specific version of mp-api / emmet-core that should be used?
Hi Kchokawa,
Could you try using the latest version of mp-api==0.46.4 and emmet-core==0.87.1? With these versions, I’m able to run the script locally and retrieve the data successfully.
I am facing the same problem. if someone has any kind of solution, please let me know too
@Urooj_Fatima I just made a fresh conda environment with mp-api==0.46.4, emmet-core==0.87.1, pymatgen-core==2026.5.18, and pymatgen==2026.5.4, and this snippet works:
from mp_api.client import MPRester
with MPRester("your_api_key_here") as mpr:
ebs = mpr.get_bandstructure_by_material_id("mp-149")
If you have anaconda, conda, or miniforge, just run:
conda create -n mp python==3.13 --yes && conda activate mp && pip install mp-api==0.46.4
1 Like
Thank you for your replys.
I updated the environment to use mp-api==0.46.4 and emmet-core==0.87.1, and the original issue was resolved.
I also noticed another small issue when trying to run the example code from the documentation:
from mp_api.client import MPRester
from emmet.core.electronic_structure import BSPathType
with MPRester("your_api_key_here") as mpr:
# -- line-mode, Setyawan-Curtarolo (default):
bs_sc = mpr.get_bandstructure_by_material_id("mp-149")
# -- line-mode, Hinuma et al.:
bs_hin = mpr.get_bandstructure_by_material_id("mp-149", path_type=BSPathType.hinuma)
# -- line-mode, Latimer-Munro:
bs_lm = mpr.get_bandstructure_by_material_id("mp-149", path_type=BSPathType.latimer_munro)
# -- uniform:
bs_uniform = mpr.get_bandstructure_by_material_id("mp-149", line_mode=False)
This gives the following import error:
ImportError: cannot import name 'BSPathType' from 'emmet.core.electronic_structure'
I was able to resolve this by changing the import to:
from emmet.core.band_theory import BSPathType
1 Like
Hi @kchokawa,
Thank you for pointing that out! We’ve updated our documentation accordingly.
We’ve recently refactored and made some changes to our stack. You’re right that
from emmet.core.band_theory import BSPathType
is the correct import.