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

Importing "Iterable" needs updating for Python > 3.9 #183

Closed
nbrunett opened this issue Feb 11, 2022 · 1 comment · Fixed by #184
Closed

Importing "Iterable" needs updating for Python > 3.9 #183

nbrunett opened this issue Feb 11, 2022 · 1 comment · Fixed by #184

Comments

@nbrunett
Copy link
Contributor

I was trying to run pycprops in Python 3.10.2 (which uses astrodendro) and encountered the following import error (partial traceback to exclude my scripts and directory names):

File ".../astrodendro/__init__.py", line 3
    from .dendrogram import Dendrogram, periodic_neighbours
File ".../astrodendro/dendrogram.py", line 8
    from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections'

It looks like importing Iterable from collections has changed after Python 3.9 (see text below the first table at the top of the page here).

Changing line 8 in dendrogram.py from

from collections import Iterable

to

try:
    # Python <= 3.9
    from collections import Iterable
except ImportError:
    # Python > 3.9
    from collections.abc import Iterable

eliminated the problem for me (inspired by suggestion in the comment here).

Let me know if you need any more information.

@keflavich
Copy link
Contributor

keflavich commented Feb 11, 2022

could you please submit this as a pull request? It looks like you've found the solution so you should get credit for the change

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

Successfully merging a pull request may close this issue.

2 participants