最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

nlp - Gensim on Google Colab : ModuleNotFoundError: No module named 'numpy.strings' - Stack Overflow

programmeradmin5浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 2

I 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.

发布评论

评论列表(0)

  1. 暂无评论