akatrevorjay/pytutils

Import Error: AttributeError: module 'collections' has no attribute 'MutableMapping'

Chris-fullerton opened this issue · 0 comments

https://stackoverflow.com/a/71902541/20119529

The attribute MutableMapping from the module collections got moved into collections.abc in python3.10.

In your case, /usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/pyparsing.py uses the MutableMapping attribute of collections.

If you can acces the source code, replace all collections.MutableMapping with collections.abc.MutableMapping.

An example :

import collections 
if sys.version_info.major == 3 and sys.version_info.minor >= 10:

    from collections.abc import MutableMapping
else:
    from collections import MutableMapping

Python 3.10.11 (main, Apr 20 2023, 13:58:42) [Clang 14.0.6 ] on darwin

Occured when trying to import ProcessLocal by from pytutils.mappings import ProcessLocal:

Traceback (most recent call last):
  File "/Users/christopherchang/TEST/python_test/test.py", line 1, in <module>
    from pytutils.mappings import ProcessLocal
  File "/Users/christopherchang/miniconda3/envs/facepcs/lib/python3.10/site-packages/pytutils/mappings.py", line 23, in <module>
    class ProxyMutableMapping(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'