I've had some problems using GENSIM.
After running:
pip install --upgrade gensim
i execute:
import gensim.downloader as api
I get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-bfa495c1e338> in <cell line: 0>()
----> 1 import gensim.downloader as api
9 frames
/usr/local/lib/python3.11/dist-packages/numpy/__init__.py in __getattr__(attr)
374 _sanity_check()
375 del _sanity_check
--> 376
377 def _mac_os_check():
378 """
ModuleNotFoundError: No module named 'numpy.strings'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
I understand that the problem is in the versions of some packages that gensim uses.
Requirement already satisfied: gensim in /usr/local/lib/python3.11/dist-packages (4.3.3)
Requirement already satisfied: numpy<2.0,>=1.18.5 in /usr/local/lib/python3.11/dist-packages (from gensim) (1.26.4)
Requirement already satisfied: scipy<1.14.0,>=1.7.0 in /usr/local/lib/python3.11/dist-packages (from gensim) (1.13.1)
Requirement already satisfied: smart-open>=1.8.1 in /usr/local/lib/python3.11/dist-packages (from gensim) (7.1.0)
Requirement already satisfied: wrapt in /usr/local/lib/python3.11/dist-packages (from smart-open>=1.8.1->gensim) (1.17.2)
How to resolve this issue?
I've had some problems using GENSIM.
After running:
pip install --upgrade gensim
i execute:
import gensim.downloader as api
I get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-bfa495c1e338> in <cell line: 0>()
----> 1 import gensim.downloader as api
9 frames
/usr/local/lib/python3.11/dist-packages/numpy/__init__.py in __getattr__(attr)
374 _sanity_check()
375 del _sanity_check
--> 376
377 def _mac_os_check():
378 """
ModuleNotFoundError: No module named 'numpy.strings'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
I understand that the problem is in the versions of some packages that gensim uses.
Requirement already satisfied: gensim in /usr/local/lib/python3.11/dist-packages (4.3.3)
Requirement already satisfied: numpy<2.0,>=1.18.5 in /usr/local/lib/python3.11/dist-packages (from gensim) (1.26.4)
Requirement already satisfied: scipy<1.14.0,>=1.7.0 in /usr/local/lib/python3.11/dist-packages (from gensim) (1.13.1)
Requirement already satisfied: smart-open>=1.8.1 in /usr/local/lib/python3.11/dist-packages (from gensim) (7.1.0)
Requirement already satisfied: wrapt in /usr/local/lib/python3.11/dist-packages (from smart-open>=1.8.1->gensim) (1.17.2)
How to resolve this issue?
Share Improve this question edited Mar 26 at 18:14 desertnaut 60.5k32 gold badges155 silver badges181 bronze badges asked Mar 17 at 18:34 robintuxrobintux 1311 silver badge11 bronze badges1 Answer
Reset to default 2I believe numpy.strings
is a numpy-2.x thing - so really shouldn't be referenced by any code the environment where the version of Gensim that you're using requires a <2.0 numpy.
Did you restart the Colab session after doing the Gensim upgrade (which also would have downgraded numpy
& scipy
to pre numpy-2.0
versions? (That's often required when changing the underlying Python environment in the middle of a running interpreter/runtime session, and I thought Colab used to wanr when this was a good idea, but it didn't just now when I tried.)
If that doesn't resolve the issue, try using the ipython magic command %xmode Verbose
before triggering the problem, to get a more detailed error – and edit that full error with all traceback frames into your question. That might reveal what code is actually referencing numpy.strings
, pointing at where the problem really lies & other possible fixes.