2025, Oct 19 23:00
Resolve gensim install failures on Windows: SciPy metadata-generation-failed and missing Fortran compiler (use Python 3.12)
Gensim install on Windows failing with SciPy metadata-generation-failed and no Fortran compiler? Learn why Python 3.13 triggers it and the fix: use Python 3.12.
Installing gensim on Windows can unexpectedly fail with a SciPy build error, even if your toolchain looks complete. The core symptom is a metadata-generation failure for SciPy during a pip install. This guide unpacks what is happening and how to get a clean install without wrestling with compilers.
What fails and how it looks
The failure typically appears when running a straightforward install command. The session ends with a SciPy metadata error, including Meson output and repeated messages that no Fortran compiler is available.
pip install gensim
Collecting gensim
  Using cached gensim-4.3.3.tar.gz (23.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy<2.0,>=1.18.5 (from gensim)
  Using cached numpy-1.26.4.tar.gz (15.8 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting scipy<1.14.0,>=1.7.0 (from gensim)
  Using cached scipy-1.13.1.tar.gz (57.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [...snip...]
      ERROR: Unknown compiler(s): [['ifort'], ['gfortran'], ['flang-new'], ['flang'], ['pgfortran'], ['g95']]
      Running `ifort --help` gave "Den angivne fil blev ikke fundet"
      Running `gfortran --help` gave "Den angivne fil blev ikke fundet"
[...snip...]
error: metadata-generation-failedThat Danish line means “The specified file was not found,” which is consistent with a missing compiler.
What is actually happening
Gensim pins SciPy to a pre-1.14.0 release because it uses a SciPy private API that was deprecated long ago and moved in SciPy 1.14.0. In practice, that means pip tries to install SciPy 1.13.x to satisfy gensim. On Python 3.13, there are no prebuilt wheels for SciPy 1.13.x, as that SciPy line does not support Python 3.13. Pip falls back to building SciPy from source, which triggers Meson and a Fortran toolchain probe. With no Fortran compiler found, the build aborts during metadata preparation.
The SciPy toolchain policy confirms the lack of builds for that Python/SciPy combination. See the Toolchain Roadmap: https://docs.scipy.org/doc/scipy/dev/toolchain.html#numpy.
Practical fixes
There are three straightforward paths forward. You can use a Python version that SciPy 1.13.1 supports. You can build SciPy 1.13.1 from source, accepting the complexity of setting up a Fortran toolchain on Windows. Or you can modify gensim to work with newer SciPy, removing the legacy dependency. Each path is viable, but they differ in cost and risk.
The least painful route is to run gensim on Python 3.12 or an older version supported by SciPy 1.13.1. That avoids the source build entirely because prebuilt wheels exist.
Applying the simplest solution: use Python 3.12
Create and use an environment with Python 3.12, then install gensim. Below are minimal examples with common tooling.
# Using conda
conda create -y -n gensim312 python=3.12
conda activate gensim312
pip install --upgrade pip
pip install gensim# Using venv (if you prefer pip/venv)
python3.12 -m venv .venv312
.venv312\Scripts\activate
python -m pip install --upgrade pip
pip install gensimAfter installation, a quick import check confirms the stack is consistent without forcing a SciPy source build.
python -c "import gensim, scipy; print(gensim.__version__, scipy.__version__)"Alternative paths (with caveats)
Building SciPy 1.13.1 from source on Windows is possible, but it is nontrivial and will require a Fortran compiler setup. The official guide for that version is here: https://docs.scipy.org/doc/scipy-1.13.1/building/index.html. Expect a challenging experience, especially when pairing an older SciPy with a very new Python release.
Refactoring gensim to work against newer SciPy is another option. The crux is eliminating access to SciPy’s private API that moved in SciPy 1.14.0. The discussion is tracked here: https://github.com/piskvorky/gensim/issues/3623.
Why you should care
Binary compatibility in Python’s scientific stack hinges on synchronized version support across NumPy, SciPy, compilers, and Python itself. A single outdated constraint in an upstream library can silently push your installer into source-build territory, where native toolchains and compilers are mandatory. Understanding these constraints saves hours of chasing toolchain errors unrelated to your actual use case.
Takeaways
If pip tries to build SciPy from source while you are installing gensim and fails with Meson or a missing Fortran compiler, you are almost certainly on Python 3.13 with a SciPy pin that predates 1.14.0. The most efficient fix is to install and use Python 3.12 for that environment, which restores access to prebuilt SciPy wheels and avoids the native build altogether. Building SciPy yourself or patching gensim are valid but heavier options. Keeping an eye on library compatibility matrices and project issue trackers will help you choose the least resistant path the next time a similar pin surfaces.
The article is based on a question from StackOverflow by Choptdei and an answer by Nick ODell.