materialsproject / api

New API client for the Materials Project
https://materialsproject.github.io/api/
Other
105 stars 33 forks source link

how to solve the bug #888

Closed xiaowangfeng closed 4 months ago

xiaowangfeng commented 4 months ago

when i run import pymatgen from mp_api.client import MPRester from pymatgen.io.cif import CifWriter

API_KEY = "***" # 注册账号时给的KEY,具体位置是官网右上角my DashBoard mpr = MPRester(API_KEY) # 创建MPRester对象进行认证

docs = mpr.summary.search(band_gap=value, total_magnetization=value) # 这里设定搜索条件 id_list = [] for doc in docs: # 获取材料索引号 id_list.append(doc.material_id)

for id in id_list: # 读取材料的晶体结构并且下载 structure = mpr.get_structure_by_material_id(id) cif_writer = CifWriter(structure) cif_writer.write_file("SemiDatasets/" + id + ".cif")

Traceback (most recent call last): File "E:\materials_discovery-main\materials_discovery-main\untitled\material.py", line 2, in from mp_api.client import MPRester File "D:\Anaconda\envs\DL\lib\site-packages\mp_api\client__init__.py", line 8, in from .mprester import MPRester File "D:\Anaconda\envs\DL\lib\site-packages\mp_api\client\mprester.py", line 10, in from emmet.core.electronic_structure import BSPathType File "D:\Anaconda\envs\DL\lib\site-packages\emmet\core\electronic_structure.py", line 11, in from pymatgen.analysis.magnetism.analyzer import ( File "D:\Anaconda\envs\DL\lib\site-packages\pymatgen\analysis\magnetism__init__.py", line 5, in from pymatgen.analysis.magnetism.analyzer import ( File "D:\Anaconda\envs\DL\lib\site-packages\pymatgen\analysis\magnetism\analyzer.py", line 24, in from pymatgen.transformations.advanced_transformations import MagOrderingTransformation, MagOrderParameterConstraint File "D:\Anaconda\envs\DL\lib\site-packages\pymatgen\transformations\advanced_transformations.py", line 33, in from pymatgen.io.ase import AseAtomsAdaptor File "D:\Anaconda\envs\DL\lib\site-packages\pymatgen\io\ase.py", line 44, in class MSONAtoms(Atoms, MSONable): NameError: name 'Atoms' is not defined

how to solve the bug i don‘t know my e-mail:578855392@qq.com

xiaowangfeng commented 4 months ago

from mp_api.client import MPRester it isn't ok。

munrojm commented 4 months ago

Pymatgen has been pinned in the latest client release to < 2024.2.20 until the bug is fixed over there.

xiaowangfeng commented 4 months ago

which version of Pymatgen can be used?

munrojm commented 4 months ago

Reinstall the latest version of the api client and it will enforce the correct pymatgen version.

xiaowangfeng commented 4 months ago

thanks,i solve the bug. i want to download the dataset, but i dont't know how to do it . could you help me? thanks again

munrojm commented 4 months ago

You will have to be more specific with what you need

xiaowangfeng commented 4 months ago

You will have to be more specific with what you need

for example if t nend to 'Find Si and O containing materials with a band gap greater than 0.5eV but less than 1.0eV', how to find and download the dataset. thanks