I am trying to use Gensim, but running import gensim
raises this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/dist-packages/gensim/__init__.py", line 11, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401
File "/usr/local/lib/python3.10/dist-packages/gensim/corpora/__init__.py", line 6, in <module>
from .indexedcorpus import IndexedCorpus # noqa:F401 must appear before the other classes
File "/usr/local/lib/python3.10/dist-packages/gensim/corpora/indexedcorpus.py", line 14, in <module>
from gensim import interfaces, utils
File "/usr/local/lib/python3.10/dist-packages/gensim/interfaces.py", line 19, in <module>
from gensim import utils, matutils
File "/usr/local/lib/python3.10/dist-packages/gensim/matutils.py", line 20, in <module>
from scipy.linalg import get_blas_funcs, triu
ImportError: cannot import name 'triu' from 'scipy.linalg' (/usr/local/lib/python3.10/dist-packages/scipy/linalg/__init__.py)
Why is this happening and how can I fix it?
I found the issue.
The
scipy.linalg
functionstri
,triu
&tril
are deprecated and will be removed in SciPy 1.13.
So, I installed SciPy v1.10.1 instead of the latest version and it was working well.
pip install scipy==1.10.1