0

我在spyder3. 我在执行以下操作时遇到错误:

mp=MPRester('api key')

data = mp.query(criteria={}, properties=['task_id']) #this line raises error

错误是:

NameError: name '**IProgress**' is not defined.

在处理上述异常的过程中,又出现了一个异常:

ImportError: **FloatProgress** not found. Please update jupyter and ipywidgets.

但我没有使用Jupyter notebook并且ipywidgets已更新。在Google 协作中工作时不会发生此问题。

4

2 回答 2

2

安装这两个对我有用:

pip install ipywidgets IProgress
于 2021-01-24T15:51:16.303 回答
1

我没有回答错误,而是为我展示了一个有效的脚本。使用以下方法可能会有所帮助。

from pymatgen import MPRester
api = MPRester("your key")

# criteria you want
criteria={"elements":{"$all": ["O"]}, "nelements":{'$lt':4}}

# properties you want
properties = ["pretty_formula", "cif", "material_id"]

c = api.query(criteria=criteria,properties=properties)
于 2020-06-08T15:50:43.620 回答