3

I am simply doing the following import statements:

from gensim.test.utils import common_texts
from gensim.models import Word2Vec

but I keep getting the following error

Traceback (most recent call last):
  File "/Users/user/PycharmProjects/COMP34711-NLP-CW2/main.py", line 15, in <module>
    from gensim.test.utils import common_texts
  File "/Users/user/.conda/envs/COMP34711-NLP-CW2/lib/python3.8/site-packages/gensim/__init__.py", line 11, in <module>
    from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils  # noqa:F401
  File "/Users/user/.conda/envs/COMP34711-NLP-CW2/lib/python3.8/site-packages/gensim/corpora/__init__.py", line 6, in <module>
    from .indexedcorpus import IndexedCorpus  # noqa:F401 must appear before the other classes
  File "/Users/user/.conda/envs/COMP34711-NLP-CW2/lib/python3.8/site-packages/gensim/corpora/indexedcorpus.py", line 14, in <module>
    from gensim import interfaces, utils
  File "/Users/user/.conda/envs/COMP34711-NLP-CW2/lib/python3.8/site-packages/gensim/interfaces.py", line 19, in <module>
    from gensim import utils, matutils
  File "/Users/user/.conda/envs/COMP34711-NLP-CW2/lib/python3.8/site-packages/gensim/matutils.py", line 1024, in <module>
    from gensim._matutils import logsumexp, mean_absolute_difference, dirichlet_expectation
  File "gensim/_matutils.pyx", line 1, in init gensim._matutils
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

I have tried updating my Numpy package (as per this answer) to 1.21.4 (the latest at the time of this post), but I still keep getting the same issue.

Update: It seems like there is a bit of incompatibility between Gensim and Apple's M1 processors as per these github issues opened in the official Gensim repository. This issue specifically, shows my exact issue with it.

knowledge_seeker
  • 811
  • 1
  • 8
  • 18

1 Answers1

1

How did you install gensim?

You may want to try uninstalling gensim & reinstalling it, after the numpy was updated, to be sure any installation-time choices/compilations use the updated numpy?

If that does not help, you may want to try starting over in a fresh conda environment, and being sure to install a fresh numpy 1st, then gensim.

gojomo
  • 52,260
  • 14
  • 86
  • 115
  • 1
    That ended up working for me so thank you! I uninstalled numpy and gensim then downladed numpy again with 'pip install -U numpy' and then 'pip install gensim' and the error went away – William Addison Jul 18 '23 at 14:38