1
import gensim
import numpy
import scipy
print("gensim version:", gensim.__version__)
print("numpy version:", numpy.__version__)
print("scipy version:", scipy.__version__)

ValueError                                Traceback (most recent call last)
<ipython-input-17-4e23b2e74105> in <cell line: 0>()
----> 1 import gensim
      2 import numpy
      3 import scipy
      4 print("gensim version:", gensim.__version__)
      5 print("numpy version:", numpy.__version__)

13 frames
/usr/local/lib/python3.11/dist-packages/numpy/random/_pickle.py in <module>
----> 1 from .mtrand import RandomState
      2 from ._philox import Philox
      3 from ._pcg64 import PCG64, PCG64DXSM
      4 from ._sfc64 import SFC64
      5 

numpy/random/mtrand.pyx in init numpy.random.mtrand()

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

although


!pip show gensim

worked perfectly

I have trouble with neither in VSCode

When I tried installing gensim, pip flagged a package incompatibility, it has something to do with fastai,thinc,spacy but I couldn't find those packages in VSCode. I uninstalled thinc, spaCy, and fastai, assuming they weren't related to gensim.

by the way libraries version in VSCode are

gensim version: 4.3.3

numpy version: 1.26.4

scipy version: 1.13.1

New contributor
Nguyễn Anh Minh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • What python version are you using?
    – dev_light
    Commented 13 hours ago
  • I ran into a similar problem when trying to use gensim. For the version of gensim I used, it required the numpy version 1.22.X but as I was using python 3.11, numpy 1.22.X could not be installed. I had to install python 3.8 to gensim Commented 10 hours ago

1 Answer 1

0

Your error is due to numpy 2.0 in any of the dependant packages.

---------------------------------------------------------------

I see you are using python 3.11.

I am able to successfully install gensim on my python 3.11 with these configurations:

gensim version: 4.3.3
numpy version: 1.26.4
scipy version: 1.13.1

-----------------------------------------------------------------

You need to start a fresh new notebook/page then install these packages.

----------------------------------------------------------------

You will get a pip's dependency resolver error for thinc 8.3.6 requires numpy<3.0.0,>=2.0.0, but you have numpy 1.26.4 which is incompatible.

But,

pip install gensim

will work and genism will be installed.

Successfully installed gensim-4.3.3 numpy-1.26.4 scipy-1.13.1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.