Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gensim install in Python 3.11 fails because of missing longintrepr.h file

Operating System: macOS Monterey 12.6 Chip: Apple M1 Python version: 3.11.1

I try:

pip3 install gensim

The install process starts well but fatally fails towards the end while running 'clang'. The error message is:

clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -I/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/numpy/core/include -c gensim/models/word2vec_inner.c -o build/temp.macosx-10.9-universal2-cpython-311/gensim/models/word2vec_inner.o
      gensim/models/word2vec_inner.c:217:12: fatal error: 'longintrepr.h' file not found
        #include "longintrepr.h"
                 ^~~~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

This issue is raised in a couple of github postings and is attributed to some incompatibility between cython and python 3.11. However, no suggestion is forwarded as to what users should do until cython is updated. I may have misrepresented the details of the discussions on github but I think this is the gist of it.

Can anyone help me in installing gensim in the meantime?

Thanks.

I updated cython and aiohttp. The latter because I had seen a post where the aiohttp install failed for the same reason as mine (missing "longintrepr.h").

No improvement. "pip install gensim" still fails and fails with the same message as copied above.

like image 575
Halim Gurgenci Avatar asked Sep 13 '25 05:09

Halim Gurgenci


2 Answers

I also faced the same issue for gensim library on Windows laptop while using Python 3.11.1 Changing to the Python 3.10 worked for me.

like image 70
Arya Stark Avatar answered Sep 14 '25 21:09

Arya Stark


I had a similar issue with Python3.11 while building Pycrypto on GNU/Linux. As a dirty workaround, I copied https://github.com/python/cpython/blob/main/Include/cpython/longintrepr.h to /usr/include/python3.11/longintrepr.h and it worked!

like image 24
Srikant Avatar answered Sep 14 '25 21:09

Srikant