Fix "error: subprocess-exited-with-error" and "Failed building wheel" with pip
error: subprocess-exited-with-error
- ERROR: Failed building wheel for numpy
- ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
- ERROR: Failed to build installable wheels for some pyproject.toml based projects (numpy)
- × Getting requirements to build wheel did not run successfully.
- error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools"
pip did not find a prebuilt wheel for your Python version, OS or CPU, so it tried to compile the package from source and the build failed (missing compiler, headers or Rust). "subprocess-exited-with-error" is only the wrapper: the real cause is higher up in the log. Most of the time, using a Python version the package ships wheels for, or a newer version of the package, is enough; otherwise, install the build tools.
What this error means
A wheel (.whl) is a package already compiled for a precise combination: Python version (cp313), system and architecture (manylinux_x86_64, macosx_arm64, win_amd64). When no wheel matches (Python too new, pinned version too old, Alpine, 32-bit ARM, 32-bit Python on Windows), pip downloads the sources (sdist) and runs their build backend (setuptools, meson-python, maturin) in a subprocess. If a C/C++ or Rust compiler, or headers such as Python.h, are missing, that subprocess exits with an error: pip prints "subprocess-exited-with-error", then "Failed building wheel". The "× … did not run successfully" block and the lines right above it contain the real error.
Common causes
- Python version with no wheel for this package: a pinned version such as
numpy==1.24.4ships no wheel for Python 3.12 and later, or you are on a Python release that came out a few weeks ago. - No compiler: Windows without "Microsoft C++ Build Tools", macOS without the Command Line Tools, Linux without
gcc/build-essential. - Missing system headers or libraries:
Python.h: No such file or directory(python3-devpackage),pg_config executable not found(psycopg2),mysql_config not found(mysqlclient). - Rust toolchain required: packages such as
cryptography,pydantic-core,tokenizersororjsonbuild with Rust when no wheel exists for the platform. - Outdated pip or uncommon platform: an old pip does not recognise recent tags (
manylinux_2_28, macOS arm64) and skips wheels that do exist; Alpine (musl) or a 32-bit Raspberry Pi have fewer wheels.
Step-by-step fix
-
Read the real error above
Scroll up in the output to the "× Building wheel for … did not run successfully" or "Getting requirements to build wheel" block and look for the first
error:line. pip verbose mode gives more details.python -m pip install -v numpy 2>&1 | tail -n 80 -
Check Python and update pip
Note the Python version and architecture (a 32-bit Python on Windows has almost no wheels), then update pip so it recognises recent wheels.
python --version python -c "import platform, struct; print(platform.machine(), struct.calcsize('P') * 8, 'bits')" python -m pip install --upgrade pip setuptools wheel -
Pick a package version that has a wheel
--only-binary :all:refuses any build: pip picks a version with a wheel or fails right away saying none exists. Upgrade an outdated version pinned inrequirements.txt, or use a binary variant.python -m pip install --only-binary :all: numpy python -m pip install --upgrade "numpy>=2" python -m pip install psycopg2-binary -
Use a supported Python version
If the package does not ship wheels for your Python yet, create the environment with the previous version.
uvdownloads the requested version on macOS, Linux and Windows; on Windows, thepylauncher works too.# uv (macOS / Linux / Windows) uv venv --python 3.12 # Windows launcher py -3.12 -m venv .venv # pyenv (macOS / Linux) pyenv install 3.12 pyenv local 3.12 python -m venv .venv -
Install the build tools
If you really need to compile, install your system’s compiler and headers. On Windows, install Visual Studio Build Tools and tick the "Desktop development with C++" workload. For Rust packages, install Rust with rustup (on Windows:
rustup-init.exe).# Debian / Ubuntu sudo apt install build-essential python3-dev pkg-config # Fedora / RHEL sudo dnf install gcc gcc-c++ python3-devel # macOS xcode-select --install # Windows (then add the C++ workload in the installer) winget install Microsoft.VisualStudio.2022.BuildTools # Rust toolchain (macOS / Linux) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -
Docker: start from a Debian image rather than Alpine
Alpine images use musl, for which many packages ship no wheel: everything gets compiled, slowly.
python:3.12-slim(Debian, glibc) gets the manylinux wheels.FROM python:3.12-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . .
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Pin the project’s Python version (
requires-pythoninpyproject.toml, a.python-versionfile) and test it in CI. - Before moving to a new Python version, check the PyPI "Download files" tab to make sure your compiled dependencies ship wheels for it.
- Use a lock file (
uv.lock,pip-tools) to install the same, already tested versions everywhere.
Frequently asked questions
Is "subprocess-exited-with-error" a pip bug?
No. pip only reports that the package build subprocess failed. The cause is in the lines above: a missing compiler, header or library.
Do I need the full Visual Studio on Windows?
No. "Build Tools for Visual Studio" with the "Desktop development with C++" workload is enough. But first check whether a wheel exists for another Python version.
Why does the install work on a colleague’s machine but not mine?
You do not have the same Python version, OS or architecture (Apple Silicon versus Intel Mac, 32- or 64-bit Python): they get a wheel, you do not.
Useful tools for this error
More Python errors
- Fix "ModuleNotFoundError: No module named" in Python
- Fix "IndentationError: unexpected indent" in Python
- Fix "'NoneType' object is not subscriptable" in Python
- Fix "error: externally-managed-environment" with pip
- Fix "UnicodeDecodeError: 'utf-8' codec can't decode byte" in Python
- Fix "KeyError" in Python (dict, pandas, os.environ)
- Fix "RecursionError: maximum recursion depth exceeded" in Python
- Fix "attempted relative import with no known parent package" in Python