arvoelke / nengolib

Nengo library of additional extensions
Other
29 stars 6 forks source link

AttributeError: module 'collections' has no attribute 'MutableMapping' #190

Open carlosgmartin opened 1 year ago

carlosgmartin commented 1 year ago
$ python3 -c "import nengolib"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/carlos/Library/Python/3.11/lib/python/site-packages/nengolib/__init__.py", line 51, in <module>
    from .connection import Connection
  File "/Users/carlos/Library/Python/3.11/lib/python/site-packages/nengolib/connection.py", line 1, in <module>
    import nengo
  File "/usr/local/lib/python3.11/site-packages/nengo/__init__.py", line 17, in <module>
    from .base import Process
  File "/usr/local/lib/python3.11/site-packages/nengo/base.py", line 7, in <module>
    from nengo.config import SupportDefaultsMixin
  File "/usr/local/lib/python3.11/site-packages/nengo/config.py", line 19, in <module>
    from nengo.params import Default, is_param, iter_params
  File "/usr/local/lib/python3.11/site-packages/nengo/params.py", line 8, in <module>
    from nengo.utils.compat import (int_types, is_array, is_array_like, is_integer,
  File "/usr/local/lib/python3.11/site-packages/nengo/utils/__init__.py", line 18, in <module>
    from . import simulator
  File "/usr/local/lib/python3.11/site-packages/nengo/utils/simulator.py", line 6, in <module>
    from .stdlib import groupby
  File "/usr/local/lib/python3.11/site-packages/nengo/utils/stdlib.py", line 19, in <module>
    class WeakKeyDefaultDict(collections.MutableMapping):
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'MutableMapping'

This was fixed in https://github.com/nengo/nengo/commit/e9a62698904915f0071deea8cf392903439a57c5 by changing collections.MutableMapping to collections.abc.MutableMapping, but nengolib is pinned to nengo<3.0. Manually upgrading nengo:

$ python3 -m pip install --upgrade nengo

yields another error:

$ python3 -c "import nengolib"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/carlos/Library/Python/3.11/lib/python/site-packages/nengolib/__init__.py", line 53, in <module>
    from .monkeypatch import patch, unpatch
  File "/Users/carlos/Library/Python/3.11/lib/python/site-packages/nengolib/monkeypatch.py", line 3, in <module>
    from nengolib.network import Network
  File "/Users/carlos/Library/Python/3.11/lib/python/site-packages/nengolib/network.py", line 4, in <module>
    from nengolib.stats.ntmdists import ball, sphere
  File "/Users/carlos/Library/Python/3.11/lib/python/site-packages/nengolib/stats/__init__.py", line 38, in <module>
    from .ntmdists import *
  File "/Users/carlos/Library/Python/3.11/lib/python/site-packages/nengolib/stats/ntmdists.py", line 7, in <module>
    from nengo.utils.compat import is_integer
ModuleNotFoundError: No module named 'nengo.utils.compat'

Related:

It looks like these were last edited in December 2019. Will there be any fix in the foreseeable future?

arvoelke commented 1 year ago

The idea has been that nengo 3.0+ and its officially supported libraries would subsume the main use cases for nengolib. I'm currently open to accepting simple patches for nengolib but if there is something in here that you can't find in the official nengo ecosystem it would be better to open up a request for support on the Nengo forum or a GitHub issue for the relevant Nengo library.