Unable to install gensim with Python 3.12 (on Alpine)
Author: AmodioCreated Dec 8, 2025Updated Dec 8, 2025
Hello, on Alpine Linux I am unable to install gensim with pip:
$ pip3 install gensim --break-system-packages
Defaulting to user installation because normal site-packages is not writeable
Collecting gensim
Using cached gensim-4.4.0.tar.gz (23.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.18.5 in /home/da/.local/lib/python3.12/site-packages (from gensim) (2.3.5)
Collecting scipy>=1.7.0 (from gensim)
Using cached scipy-1.16.3-cp312-cp312-musllinux_1_2_x86_64.whl.metadata (62 kB)
Collecting smart_open>=1.8.1 (from gensim)
Using cached smart_open-7.5.0-py3-none-any.whl.metadata (24 kB)
Collecting wrapt (from smart_open>=1.8.1->gensim)
Using cached wrapt-2.0.1-cp312-cp312-musllinux_1_2_x86_64.whl.metadata (9.0 kB)
Using cached scipy-1.16.3-cp312-cp312-musllinux_1_2_x86_64.whl (38.7 MB)
Using cached smart_open-7.5.0-py3-none-any.whl (63 kB)
Using cached wrapt-2.0.1-cp312-cp312-musllinux_1_2_x86_64.whl (120 kB)
Building wheels for collected packages: gensim
Building wheel for gensim (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for gensim (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [758 lines of output]
/tmp/pip-build-env-s5ikopsa/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py:289: UserWarning: Unknown distribution option: 'test_suite'
warnings.warn(msg)
/tmp/pip-build-env-s5ikopsa/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py:289: UserWarning: Unknown distribution option: 'tests_require'
[...]
/usr/include/python3.12/cpython/dictobject.h:22:34: note: declared here
22 | Py_DEPRECATED(3.12) uint64_t ma_version_tag;
| ^~~~~~~~~~~~~~
gensim/models/word2vec_inner.c: In function '__Pyx_PyInt_As_PY_LONG_LONG':
gensim/models/word2vec_inner.c:12812:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
12812 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c:12867:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
12867 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c: In function '__Pyx_PyInt_As_int':
gensim/models/word2vec_inner.c:13046:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13046 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c:13101:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13101 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c: In function '__Pyx_PyInt_As_unsigned_PY_LONG_LONG':
gensim/models/word2vec_inner.c:13242:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13242 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c:13297:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13297 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c: In function '__Pyx_PyInt_As_npy_uint32':
gensim/models/word2vec_inner.c:13438:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13438 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c:13493:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13493 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c: In function '__Pyx_PyInt_As_long':
gensim/models/word2vec_inner.c:13634:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13634 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c:13689:53: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
13689 | const digit* digits = ((PyLongObject*)x)->ob_digit;
| ^~
gensim/models/word2vec_inner.c: In function '__Pyx_PyIndex_AsSsize_t':
gensim/models/word2vec_inner.c:14208:45: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
14208 | const digit* digits = ((PyLongObject*)b)->ob_digit;
| ^~
error: command '/usr/bin/cc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for gensim
Failed to build gensim
ERROR: Failed to build installable wheels for some pyproject.toml based projects (gensim)An old version of cython was used to generate the .c files (/* Generated by Cython 0.29.32 */) in the pip pkg. Could you please update it?
Related bugs/discussions (that seem a bit old to me): #5238 & !101292.
I have the latest available versions (cython-3.1.6-r0) on Alpine and compiling this repo directly fixed the issue.
Source: piskvorky/gensim