I used the interactive “Binder” notebook, preinstalled with Materials Project software, and get the below errors when I run the sample code snippet to retrieve the data.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [5], in <module>
7 structure = mpr.get_structure_by_material_id('mp-998908')
9 # important to use the conventional structure to ensure
10 # that peaks are labelled with the conventional Miller indices
---> 11 sga = SpacegroupAnalyzer(structure)
12 conventional_structure = sga.get_conventional_standard_structure()
14 # this example shows how to obtain an XRD diffraction pattern
15 # these patterns are calculated on-the-fly from the structure
File /srv/conda/envs/notebook/lib/python3.9/site-packages/pymatgen/symmetry/analyzer.py:59, in SpacegroupAnalyzer.__init__(self, structure, symprec, angle_tolerance)
57 self._angle_tol = angle_tolerance
58 self._structure = structure
---> 59 self._siteprops = structure.site_properties
60 latt = structure.lattice.matrix
61 positions = structure.frac_coords
AttributeError: 'NoneType' object has no attribute 'site_properties'
Hi @jaidah_mohan. I can’t reproduce this. I copied the example below, except pasting in my own personal API key:
from mp_api import MPRester
from pymatgen.analysis.diffraction.xrd import XRDCalculator
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
with MPRester(api_key='<enter your api key>') as mpr:
# first retrieve the relevant structure
structure = mpr.get_structure_by_material_id('mp-998908')
# important to use the conventional structure to ensure
# that peaks are labelled with the conventional Miller indices
sga = SpacegroupAnalyzer(structure)
conventional_structure = sga.get_conventional_standard_structure()
# this example shows how to obtain an XRD diffraction pattern
# these patterns are calculated on-the-fly from the structure
calculator = XRDCalculator(wavelength='CuKa')
pattern = calculator.get_pattern(conventional_structure)
And this works fine.
Is there any other information you can provide to help reproduce the issue?
Best,
Matt
Hi. To get XRD data for material mp-17254 I ran above script (and other similar ones) several times. But each time I got an error on the first line: launcher cannot find or install MPRester. Then naturally it cannot proceed to generate XRD data for the material. How can I solve this problem. PS: I am not a programmer guy. Thanks in advance.
Please try to follow the docs and install mp_api
in a python environment on your computer. We do not maintain an up-to-date notebook on Binder anymore, unfortunately.
1 Like
Oh thanks, I’ll try it, and be sure come back with lots of new questions 