Skip to content
Latchkey

pip "Building wheel for X did not run successfully" (Cython) in CI

pip ran the project's wheel build, which invoked Cython to translate .pyx sources to C and then compile them. The Cython or compile step exited non-zero, so no wheel was produced.

What this error means

pip prints "Building wheel for X (pyproject.toml) ... error" with Cython output such as a missing Cython module, a .pyx syntax error, or a C compiler failure on the generated file.

pip
  Building wheel for pandas (pyproject.toml) ... error
  error: subprocess-exited-with-error

  Cython.Compiler.Errors.CompileError: pandas/_libs/tslib.pyx
  ERROR: Failed building wheel for pandas

Common causes

Cython is not installed or too old

The build needs a specific Cython version to translate .pyx files; an absent or outdated Cython fails compilation.

No prebuilt wheel for this Python/platform

When a binary wheel is unavailable, pip compiles from source, which requires the full Cython + C toolchain to succeed.

How to fix it

Prefer a prebuilt wheel for the package

  1. Check whether the package publishes a wheel for the runner's Python version.
  2. Pin to a version with a manylinux wheel, or align the CI Python version to one that has wheels.
  3. Use --only-binary to refuse a source build.
Terminal
pip install --only-binary=:all: "pandas==2.2.2"

Provision the build toolchain if you must compile

When a source build is unavoidable, install a matching Cython and a C compiler before building.

Terminal
python -m pip install --upgrade pip "Cython>=3.0" setuptools wheel
sudo apt-get install -y build-essential

How to prevent it

  • Pin CI Python to a version with prebuilt wheels for your C-extension deps.
  • Use --only-binary for heavy compiled packages.
  • If you build source, pin the exact Cython version the project expects.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →