ImportError in Pymatgen

Anyone understand why this may be happening as I try to connect to the Materials Project API?

Its very frustrating.

Try first updating pymatgen with pip install -U pymatgen. It seems like you have an old version because the pymatgen.analysis.defects module was removed and put into a standalone package a while back.

Also, just a general comment – you may want to try the new MPRester. To do that you need to pip install the mp-api package and then change your import statement to: from mp_api.client import MPRester

Hope this helps!

Hi Matt,

I followed those instructions, including the MPRester , and had read elsewhere that mpymatgen.anaysis.defects was removed from pymatgen as a standalone.

Unfortunately still getting the same error, unfortunately. It’s bumming me out. Do you think I have to reinstsall everything

what is it about being partially initialized that’s causing problems?

This is a circular import error that happens when modules simultaneously import from each other, and it really shouldn’t be happening so long as you have updated pymatgen correctly. It is not something that you should have to diagnose or fix, again assuming you have installed everything correctly. Is it possible you just forgot to restart your kernel in your Jupyter notebook?

If you still have the problem after trying everything, then yes, I would suggest you make a new environment and do a fresh installation with pip install pymatgen


You can check the documentation for that method by pressing Shift+Tab. It looks like you want the mpr.get_structure_by_material_id method instead.

FYI: you should never post your API key somewhere visible online

no doubt.

Matt, sorry, any idea what it doesnt like this get version, I have boto3 installed.

I think I will step away and let you figure this one out :blush:

Hint: it’s not related to boto3. Try typing mpr. and pressing the Tab key

Hi Matt,

I’m using jupyter notebook, what is the tab key going to do for me in that context?

i see what hitting tab is doing, but I don’t see “get_data” in this version of pymatgen, hince not sure how to result the CIF struct. sorry for being a noob.

figured it out.