hmni
hmni copied to clipboard
ImportError: cannot import name 'Iterable' from 'collections'
I just pip installed it and wanted to try it out, but can't even get that far. :/
If I just have a single line: import hmni
It immediately fails with the above error. I tried running pip install a second time in case something was missed, it gave a bunch of Requirement Already Satisfied messages.
Some searching led me to try from collections.abc import Iterable but it doesn't help. Full error text follows:
Traceback (most recent call last): File "C:\Users\abc\something.py", line 1, in <module> import hmni File "C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\site-packages\hmni\__init__.py", line 1, in <module> from . import input_helpers, matcher, preprocess, siamese_network, syllable_tokenizer File "C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\site-packages\hmni\matcher.py", line 30, in <module> from abydos.distance import (IterativeSubString, BISIM, DiscountedLevenshtein, Prefix, LCSstr, MLIPNS, Strcmp95, File "C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\site-packages\abydos\distance\__init__.py", line 369, in <module> from ._ample import AMPLE File "C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\site-packages\abydos\distance\_ample.py", line 22, in <module> from ._token_distance import _TokenDistance File "C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\site-packages\abydos\distance\_token_distance.py", line 35, in <module> from ..tokenizer import QGrams, QSkipgrams, WhitespaceTokenizer File "C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\site-packages\abydos\tokenizer\__init__.py", line 99, in <module> from ._q_grams import QGrams File "C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\site-packages\abydos\tokenizer\_q_grams.py", line 22, in <module> from collections import Iterable ImportError: cannot import name 'Iterable' from 'collections' (C:\Users\abc\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)
I believe this issue is related to your Python version (>3.9)
The error is generated from abydos package; they need to modify their imports like below:
try:
# Python <= 3.9
from collections import Iterable
except ImportError:
# Python > 3.9
from collections.abc import Iterable
If the maintainer of abydos doesn't fix in the coming weeks, I'll work on patching it.
I recently ran into this issue as well with Python 3.10.6
Any updates?
I recently ran into this issue as well with Python 3.10.6
Any updates?
For a quick-fix make the necessary modifications in the abydos
package files to import Iterable class.
~~from collections import Iterable~~ => from collections.abc import Iterable
The modifications have to be made in the following files:
-
/usr/local/lib/python3.10/dist-packages/abydos/tokenizer/_q_grams.py
-
/usr/local/lib/python3.10/dist-packages/abydos/tokenizer/_q_skipgrams.py
-
/usr/local/lib/python3.10/dist-packages/abydos/distance/_synoname.py
A solution if you don't want to change package files is to create alias before importing hmni
import collections.abc
collections.Iterable = collections.abc.Iterable
import hmni
Check out this stack overflow: https://stackoverflow.com/a/72113974/10360644