MPRester import continuously running

Hi!

I am encountering a problem when trying to import MPRester: basically the code runs for minutes and is not able to finalize the code chunks. I have been trying the following import methods:

  • from pymatgen.ext.matproj import MPRester (Legacy API)
  • from pymatgen import MPRester (older version)
  • from mp_api import MPRester (new API suggested at [Materials Project - API], but the python command import mp_api seems not to work)

The simple statement from pytmatgen import ext works, but MPRester appears not to be available.

I am running on miniconda3, Python 3.10.2: any ideas about what may be happening ?

EDIT: I am working in a virtual conda environment where I only condaforged pymatgen and pip-installed mp_api
EDIT2: same happens in environments where I only use pip install for the packages
EDIT3: whatever I do, I end up in the same problem. Ctrl+c always returns the same traceback:

Traceback (most recent call last):
  File "c:\Users\(username)\Documents\Python Scripts\Materials Project\MP_api.py", line 21, in <module>
    import pymatgen.core as mg 
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\pymatgen\core\__init__.py", line 54, in <module>
    SETTINGS = _load_pmg_settings()
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\pymatgen\core\__init__.py", line 43, in _load_pmg_settings
    d_yml = yaml.load(f)
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\main.py", line 434, in load
    return constructor.get_single_data()
File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\constructor.py", line 119, in get_single_data 
    node = self.composer.get_single_node()
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\composer.py", line 76, in get_single_node     
    document = self.compose_document()
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\composer.py", line 99, in compose_document    
    node = self.compose_node(None, None)
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\composer.py", line 143, in compose_node       
    node = self.compose_mapping_node(anchor)
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\composer.py", line 223, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\composer.py", line 143, in compose_node
    node = self.compose_mapping_node(anchor)
  File "C:\Users\(username)\miniconda3\envs\pymatgen\lib\site-packages\ruamel\yaml\composer.py", line 223, in compose_mapping_node
    item_value = self.compose_node(node, item_key)

it appears to me that the import command runs in a loop of some sort (the last two lines actually repeat many times), but I can’t wrap my mind around it.

The problem was caused by a corrupted .pmgrc.yaml file. Solved by changing its name: running the script again produced a new one.

1 Like

Thanks for updating!