Type Error when Importing mp_api

When trying to import the api module, I get the error “TypeError: SeparationPlane.init() got an unexpected keyword argument ‘point_groups_permutations’”. This code worked around a week or two ago, but no longer does. This occurs from just importing, so I’m unsure what is causing this. I’ve tried reinstalling modules, updating them, and running on different versions of Python but error still occurs. Sorry if this is a noob question, and thank you in advanced for any solutions.

The full error is as follows:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[8], line 3
      1 import numpy
      2 import pandas
----> 3 from mp_api.client import MPRester
      5 with MPRester("my-api-key") as mpr:
      6     docs = mpr.materials.summary.search(formula=[formula], fields=[ 'material_id',
      7         'formation_energy_per_atom',
      8         'band_gap',
   (...)
     13         'spacegroup.number',
     14         'database_IDs'])

File ~\.conda\envs\myenv\Lib\site-packages\mp_api\client\__init__.py:8
      5 from importlib.metadata import PackageNotFoundError, version
      7 from .core import MPRestError
----> 8 from .mprester import MPRester
     10 try:
     11     __version__ = version("mp_api")

File ~\.conda\envs\myenv\Lib\site-packages\mp_api\client\mprester.py:31
     29 from mp_api.client.core.utils import validate_ids
     30 from mp_api.client.routes import GeneralStoreRester, MessagesRester, UserSettingsRester
---> 31 from mp_api.client.routes.materials import (
     32     AbsorptionRester,
     33     AlloysRester,
     34     BandStructureRester,
     35     BondsRester,
     36     ChemenvRester,
     37     DielectricRester,
     38     DOIRester,
     39     DosRester,
     40     ElasticityRester,
     41     ElectrodeRester,
     42     ElectronicStructureRester,
     43     EOSRester,
     44     GrainBoundaryRester,
     45     MagnetismRester,
     46     OxidationStatesRester,
     47     PhononRester,
     48     PiezoRester,
     49     ProvenanceRester,
     50     RobocrysRester,
     51     SimilarityRester,
     52     SubstratesRester,
     53     SummaryRester,
     54     SurfacePropertiesRester,
     55     SynthesisRester,
     56     TaskRester,
     57     ThermoRester,
     58     XASRester,
     59 )
     60 from mp_api.client.routes.materials.materials import MaterialsRester
     61 from mp_api.client.routes.molecules import MoleculeRester

File ~\.conda\envs\myenv\Lib\site-packages\mp_api\client\routes\materials\__init__.py:5
      3 from .absorption import AbsorptionRester
      4 from .bonds import BondsRester
----> 5 from .chemenv import ChemenvRester
      6 from .dielectric import DielectricRester
      7 from .doi import DOIRester

File ~\.conda\envs\myenv\Lib\site-packages\mp_api\client\routes\materials\chemenv.py:5
      1 from __future__ import annotations
      3 from collections import defaultdict
----> 5 from emmet.core.chemenv import (
      6     COORDINATION_GEOMETRIES,
      7     COORDINATION_GEOMETRIES_IUCR,
      8     COORDINATION_GEOMETRIES_IUPAC,
      9     COORDINATION_GEOMETRIES_NAMES,
     10     ChemEnvDoc,
     11 )
     13 from mp_api.client.core import BaseRester
     14 from mp_api.client.core.utils import validate_ids

File ~\.conda\envs\myenv\Lib\site-packages\emmet\core\chemenv.py:4
      1 from typing import Literal, List, Union, Optional
      3 from pydantic import Field
----> 4 from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import (
      5     SimplestChemenvStrategy,
      6 )
      7 from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import (
      8     AllCoordinationGeometries,
      9 )
     10 from pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder import (
     11     LocalGeometryFinder,
     12 )

File ~\.conda\envs\myenv\Lib\site-packages\pymatgen\analysis\chemenv\coordination_environments\chemenv_strategies.py:46
     42 __date__ = "Feb 20, 2016"
     44 module_dir = os.path.dirname(os.path.abspath(__file__))
---> 46 MPSYMBOL_TO_CN = AllCoordinationGeometries().get_symbol_cn_mapping()
     47 ALLCG = AllCoordinationGeometries()
     50 class StrategyOption(MSONable, abc.ABC):

File ~\.conda\envs\myenv\Lib\site-packages\pymatgen\analysis\chemenv\coordination_environments\coordination_geometries.py:894, in AllCoordinationGeometries.__init__(self, permutations_safe_override, only_symbols)
    892         with open(cg_file) as file:
    893             dd = json.load(file)
--> 894         self.cg_list.append(CoordinationGeometry.from_dict(dd))
    895 else:
    896     for symbol in only_symbols:

File ~\.conda\envs\myenv\Lib\site-packages\pymatgen\analysis\chemenv\coordination_environments\coordination_geometries.py:626, in CoordinationGeometry.from_dict(cls, dct)
    598 @classmethod
    599 def from_dict(cls, dct: dict) -> Self:
    600     """
    601     Reconstructs the CoordinationGeometry from its JSON-serializable dict representation.
    602 
   (...)
    607         CoordinationGeometry
    608     """
    609     return cls(
    610         mp_symbol=dct["mp_symbol"],
    611         name=dct["name"],
    612         alternative_names=dct["alternative_names"],
    613         IUPAC_symbol=dct["IUPAC_symbol"],
    614         IUCr_symbol=dct["IUCr_symbol"],
    615         coordination=dct["coordination"],
    616         central_site=dct["central_site"],
    617         points=dct["points"],
    618         solid_angles=(
    619             dct["solid_angles"]
    620             if "solid_angles" in dct
    621             else [4.0 * np.pi / dct["coordination"]] * dct["coordination"]
    622         ),
    623         deactivate=dct["deactivate"],
    624         faces=dct["_faces"],
    625         edges=dct["_edges"],
--> 626         algorithms=[MontyDecoder().process_decoded(algo_d) for algo_d in dct["_algorithms"]]
    627         if dct["_algorithms"] is not None
    628         else None,
    629         equivalent_indices=dct.get("equivalent_indices"),
    630         neighbors_sets_hints=[
    631             cls.NeighborsSetsHints.from_dict(nb_sets_hints)
    632             for nb_sets_hints in dct.get("neighbors_sets_hints") or []
    633         ]
    634         or None,
    635     )

File ~\.conda\envs\myenv\Lib\site-packages\monty\json.py:716, in MontyDecoder.process_decoded(self, d)
    713 data = {k: v for k, v in d.items() if not k.startswith("@")}
    714 if hasattr(cls_, "_from_dict"):
    715     # New functionality with save/load requires this
--> 716     return cls_._from_dict(
    717         data, name_object_map=self._name_object_map
    718     )
    719 if hasattr(cls_, "from_dict"):
    720     return cls_.from_dict(data)

File ~\.conda\envs\myenv\Lib\site-packages\monty\json.py:247, in MSONable._from_dict(cls, d, name_object_map)
    244 @classmethod
    245 def _from_dict(cls, d, name_object_map):
    246     decoded = MSONable.decoded_from_dict(d, name_object_map=name_object_map)
--> 247     return cls(**decoded)

TypeError: SeparationPlane.__init__() got an unexpected keyword argument 'point_groups_permutations'

Thanks for reaching out! I’ve edited your post for readability and removed your API key. For the future, please make sure to not share your API key anywhere (publicly).

Which versions of python, pymatgen, mp-api, emmet-core, and monty are you using? Try to make sure they’re the latest versions.

Hi, sorry for the late reply.

A colleague pointed out its likely an issue with Jupyter, and trying on a different machine worked. Apologies for the key inclusion, I’ll be sure to remove that next time.