However, your third-party allennlp code is very old. It imports MutableMapping from collections, while it was moved to collections.abc in Python 3.3 and has since been deprecated to import from there - although the reference was kept for backwards compatibility.
The reference was completely removed in Python 3.10 and onwards, so the magniture library actully doesn't work on the newest Python version, nor is it future-compatible.
The fix is simple - change line 12 in pymagnitude/third_party/allennlp/common/params.py from:
from collections import MutableMapping, OrderedDict
to
from collections import OrderedDict
from collections.abc import MutableMapping
Also, there might be some more broken imports lying around. I wouldn't know. :)
Cheers!
Reference stack trace of the error on Python 3.10.2:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [74], in <module>
----> 1 from pymagnitude import Magnitude
File ~/.pyenv/versions/3.10.2/envs/py3/lib/python3.10/site-packages/pymagnitude/__init__.py:80, in <module>
78 sys.path.append(os.path.dirname(__file__) + '/third_party/')
79 sys.path.append(os.path.dirname(__file__) + '/third_party_mock/')
---> 80 from pymagnitude.third_party.allennlp.commands.elmo import ElmoEmbedder
82 # Import SQLite
83 try:
File ~/.pyenv/versions/3.10.2/envs/py3/lib/python3.10/site-packages/pymagnitude/third_party/allennlp/commands/__init__.py:8, in <module>
4 import argparse
5 import logging
----> 8 from allennlp.commands.configure import Configure
9 from allennlp.commands.elmo import Elmo
10 from allennlp.commands.evaluate import Evaluate
File ~/.pyenv/versions/3.10.2/envs/py3/lib/python3.10/site-packages/pymagnitude/third_party/allennlp/commands/__init__.py:8, in <module>
4 import argparse
5 import logging
----> 8 from allennlp.commands.configure import Configure
9 from allennlp.commands.elmo import Elmo
10 from allennlp.commands.evaluate import Evaluate
File ~/.pyenv/versions/3.10.2/envs/py3/lib/python3.10/site-packages/pymagnitude/third_party/allennlp/commands/configure.py:25, in <module>
22 import argparse
24 from allennlp.commands.subcommand import Subcommand
---> 25 from allennlp.common.configuration import configure, Config, render_config
27 class Configure(Subcommand):
28 def add_subparser(self, name , parser ) :
29 # pylint: disable=protected-access
File ~/.pyenv/versions/3.10.2/envs/py3/lib/python3.10/site-packages/pymagnitude/third_party/allennlp/common/__init__.py:3, in <module>
2 from __future__ import absolute_import
----> 3 from allennlp.common.params import Params
4 from allennlp.common.registrable import Registrable
5 from allennlp.common.tee_logger import TeeLogger
File ~/.pyenv/versions/3.10.2/envs/py3/lib/python3.10/site-packages/pymagnitude/third_party/allennlp/common/params.py:12, in <module>
10 from __future__ import absolute_import
11 #typing
---> 12 from collections import MutableMapping, OrderedDict
13 import copy
14 import json
ImportError: cannot import name 'MutableMapping' from 'collections' (/Users/myuser/.pyenv/versions/3.10.2/lib/python3.10/collections/__init__.py)
Hey, :)
Awesome package!
However, your third-party
allennlp
code is very old. It importsMutableMapping
fromcollections
, while it was moved tocollections.abc
in Python 3.3 and has since been deprecated to import from there - although the reference was kept for backwards compatibility.The reference was completely removed in Python 3.10 and onwards, so the
magniture
library actully doesn't work on the newest Python version, nor is it future-compatible.The fix is simple - change line 12 in
pymagnitude/third_party/allennlp/common/params.py
from:to
Also, there might be some more broken imports lying around. I wouldn't know. :)
Cheers!
Reference stack trace of the error on Python 3.10.2: