Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'Sized' from 'collections' #336

Closed
andrewcrook opened this issue Feb 14, 2022 · 4 comments
Closed

ImportError: cannot import name 'Sized' from 'collections' #336

andrewcrook opened this issue Feb 14, 2022 · 4 comments

Comments

@andrewcrook
Copy link
Contributor

Python 3.10, macOS 12, M1, Jupyter notebooks (6.4.8)
Upon starting jupyter notebook
failes to load kernel and loops looks like a import error

Traceback (most recent call last):
  File "/Users/andrew/.asdf/installs/python/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/andrew/.asdf/installs/python/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/andrew/code/Jupyter/.direnv/python-3.10.1/lib/python3.10/site-packages/sos_notebook/kernel.py", line 32, in <module>
    from .completer import SoS_Completer
  File "/Users/andrew/code/Jupyter/.direnv/python-3.10.1/lib/python3.10/site-packages/sos_notebook/completer.py", line 11, in <module>
    from .magics import SoS_Magics
  File "/Users/andrew/code/Jupyter/.direnv/python-3.10.1/lib/python3.10/site-packages/sos_notebook/magics.py", line 11, in <module>
    from collections import Sized, OrderedDict, Sequence
ImportError: cannot import name 'Sized' from 'collections' (/Users/andrew/.asdf/installs/python/3.10.1/lib/python3.10/collections/__init__.py)
@andrewcrook
Copy link
Contributor Author

I am fixing right now

@andrewcrook
Copy link
Contributor Author

andrewcrook commented Feb 14, 2022

Pull request #337

Replaced collections imports with collections.abc for Sized, Sequence otherwise causes ImportError
Changed in Python 3.3.
Old method stops working in python 3.10

https://stackoverflow.com/a/70195883

@BoPeng
Copy link
Contributor

BoPeng commented Feb 14, 2022

Thanks. I have not tried 3.10 yet so I have not noticed this problem.

I have merged the PR and will check if there is any pending bug that prevents a new release.

@BoPeng BoPeng closed this as completed Feb 14, 2022
@andrewcrook
Copy link
Contributor Author

@BoPeng Thank you

FYI I removed the following notice

Please Note: collections.abc does not work for OrderedDict still have to use collections I think this need to be raised as a python issue.

Because looking at python documentation I believe this is correct collections.abc has been taken out from collections and contains the Abstract Base Classes for Containers (hence abc) whilst the other classes (specialised container datatypes providing alternatives to Python’s general purpose built-in containers), remain in collections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants