# pip: Failed building wheel / failed-wheel-build-for-install — how to fix it

> pip found no ready-made wheel for a package on your Python version and platform, tried to compile one from source, and the compiler step failed. The fix is almost never to install a compiler: move to a version of the package that ships a wheel for your Python, switch to its binary variant (psycopg[binary], psycopg2-binary), or pin the Python version the package supports.

Source: https://livops.dev/en/guides/error-pip-failed-building-wheel

By Livops team, the people who build and run Livops. Updated 23 November 2026.

Current pip (25.2 and later[7]) ends a failed install like this. The lines are pip's own messages[1][2][3][4], with `psycopg2` as the example:

```text
  error: subprocess-exited-with-error

  × Building wheel for psycopg2 (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      ...
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for psycopg2
Failed to build psycopg2
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> psycopg2
```

Older pip says the last part differently. pip 24.1 to 25.1: `ERROR: Failed to build installable wheels for some pyproject.toml based projects (psycopg2)`[6]. pip 24.0 and earlier: `ERROR: Could not build wheels for psycopg2, which is required to install pyproject.toml-based projects`[5]. Same failure, same fix.

This page explains why pip is compiling anything at all, lists the causes from the most common, gives the fix for each, and shows how to check a `requirements.txt` before you deploy it.

## What does the error mean?

Packages reach pip in two forms: a **wheel**, which is ready to install, and a **source distribution** (sdist). When pip cannot find a wheel to install, it falls back to downloading the sdist, building a wheel from it, and installing that[8][11]. For a pure-Python package that build is trivial. For a package with extension modules in C, C++ or Rust, it means compiling, and a wheel of compiled code fits only the platform it was built for[8].

A wheel's file name says what it fits: Python tag, ABI tag and platform tag, such as `cp312` for CPython 3.12 or `manylinux_2_28_x86_64` for most glibc Linux distributions; `musllinux` is the same idea for musl-based systems such as Alpine[9].

So the error is two failures in a row: no wheel matched your Python and platform, and building one from source failed. **The useful line is inside the `[N lines of output]` block**, not pip's summary under it. Scroll up to it.

## Causes, most common first

### 1. Your pinned version is older than your Python

An `==` pin written a few years ago names a release that came out before the Python you deploy on. A package with compiled code publishes wheels per Python version, so that release has wheels only for the Pythons that existed then. On a newer Python pip finds no matching wheel, only the sdist, and tries to compile it.

**Fix:** raise the pin to a release that ships a wheel for your Python. Look at the release's files on PyPI: a wheel whose name carries `cp312` and a Linux platform tag means CPython 3.12 on Linux installs it without compiling[9]. Then write the pin as a floor rather than an exact version:

```text
somepackage>=2.0     # instead of somepackage==1.4.2
```

If you cannot move the package, pin the Python version it supports instead (cause 4).

### 2. Build tools or headers are missing

The output names what is missing. For psycopg2, its docs list the messages and the cause[13]:

```text
error: Python.h: No such file or directory      # Python headers missing (python3-dev)
error: libpq-fe.h: No such file or directory    # libpq headers missing (libpq-dev)
```

and building it needs a C compiler and the `pg_config` program as well[13]. Other packages ask for other tools; `cryptography`, built from source, needs a C compiler, a Rust compiler, and the OpenSSL and libffi headers[15].

**Fix:** use a package that needs no compiling (cause 3) rather than installing a compiler where the app runs.

### 3. You install the source variant where a binary one exists

Several database drivers publish a separate binary package:

| Instead of | Use | Notes |
| --- | --- | --- |
| `psycopg2` | `psycopg2-binary` | A pre-compiled module with no build prerequisites[13] |
| `psycopg` (Psycopg 3, plain) | `psycopg[binary]` | Precompiled C extensions packaged with the client libraries[14] |
| `mysqlclient` | `PyMySQL` | Needs no compiling (see Livops below) |

Be aware of the trade-off the psycopg2 docs state: the binary package bundles its own libpq and libssl, which upgrading the system libraries does not upgrade, and the docs advise the source package for production use[13]. Psycopg 3 recommends `psycopg[binary]` for most users, and notes that binary packages for a new Python version appear only once its build runners support it[14].

```text
psycopg[binary]>=3.2
```

### 4. The Python version is too new for the package

A brand-new Python often has no wheels yet for packages with compiled code; the Psycopg note above is one example[14]. Pin the Python version your dependencies support. Check locally whether wheels exist for a given Python before you change anything (see below).

### 5. pip is too old to see the wheel

A wheel can exist and still be skipped by an old pip that does not understand its platform tag. cryptography, for example, says its Linux wheels need pip 19.3 or newer on manylinux, or pip 21.2.4 for musllinux, and suggests upgrading pip before trying to compile[15]. In a Dockerfile:

```dockerfile
RUN pip install --upgrade pip && pip install -r requirements.txt
```

### 6. It is not a compiler problem at all

Some failures happen in the same step for another reason: the package's build script cannot find a file, needs a setting, or is broken on that version. The output block says so. Then the fix is the package's: another version, or its issue tracker.

## Never compile by accident

Tell pip to refuse sdists, and a missing wheel fails immediately with a clear message instead of a page of compiler output. `--only-binary :all:` disables all source packages; `--prefer-binary` picks a wheel over a newer sdist[10]:

```sh
pip install --only-binary :all: -r requirements.txt
pip install --only-binary psycopg2,numpy -r requirements.txt
pip install --prefer-binary -r requirements.txt
```

Packages without binary distributions fail to install when `--only-binary` covers them[10] — which is the point: you find out which one has no wheel.

## How to confirm the fix locally

Check whether every package has a wheel for the Python you will deploy on. In a clean Linux container with that Python:

```sh
docker run --rm -v "$PWD":/app -w /app python:3.12-slim \
  pip install --only-binary :all: -r requirements.txt
```

Or, without Docker, ask pip to download wheels for another Python version and platform; `--python-version` and `--platform` require `--only-binary=:all:` (or `--no-deps`)[12]:

```sh
pip download --only-binary :all: --python-version 3.12 \
  --platform manylinux2014_x86_64 -d /tmp/wheels -r requirements.txt
```

A package with no matching wheel is named in the error. Change its pin or variant until the command passes, then deploy.

## On Livops

- **The deploy stops as `install_failed`.** The build log shows pip's output, and a **Tip:** line at its end points at the fix. The previous version keeps running while you fix it.
- **A second try with a compiler.** When a Python package compiles on install (`mysqlclient`, `psycopg2` and the like), Livops retries the install in an image with a compiler. If it still fails, use the variant that needs no compiling:

  ```text
  psycopg2-binary   # instead of psycopg2
  PyMySQL           # instead of mysqlclient
  ```

- **Set the Python version in a file.** Livops runs Python 3.10 to 3.14 and reads `.python-version` and `runtime.txt`. A `.python-version` at the project root with one line pins it:

  ```text
  3.12
  ```

  If the log says `Requires-Python >=3.12`, that file is the fix.
- **Contradicting pins.** `ResolutionImpossible` is a different error: two lines of `requirements.txt` ask for versions that cannot both be installed. Loosen one `==` pin, for example `aiogram>=3.4` instead of `aiogram==3.4.1`.
- **Ten minutes per build.** A build that compiles a large package from source can run past the ten-minute limit and stop as `timed_out`. A wheel installs in seconds; prefer one.
- **Start commands use the project's environment.** A Python start command you write yourself in **Settings → Start** begins with `.venv/bin/`, for example `.venv/bin/python main.py`.
- **A Dockerfile is used when the project has one.** If a package truly needs system libraries, a `Dockerfile` that installs them builds the image your way.

A Python web app costs **39 credits a month**; a bot, worker or cron job **19**. The install errors are in [Install failed](https://livops.dev/en/docs/error-install), including [A package compiles on install (Python)](https://livops.dev/en/docs/error-install#py-compiler) and [A package needs a newer Python](https://livops.dev/en/docs/error-install#python-312).

## Questions

**Is this a bug in pip?**

Almost never. pip's own note says the error originates from a subprocess and is likely not a problem with pip. pip only ran the package's build backend; the compiler or build script inside it failed, and the real error is in the lines of output above pip's summary.

**Why does it install on my laptop but fail on the server?**

Your laptop got a ready-made wheel, or already had the compiler and headers. The server runs a different Python version or platform, there is no wheel for that combination, so pip falls back to building from source, and the build tools are missing there.

**Should I install gcc and the -dev packages on the server?**

Only as a last resort. A newer release of the package usually ships a wheel for your Python, and many packages have a binary variant. Compiling on every deploy is slow, and on a platform without root you cannot install system packages anyway.

**Is psycopg2-binary fine for production?**

The psycopg2 docs advise the source package for production, because the binary bundles its own libpq and libssl that system updates do not touch. For new code, Psycopg 3 with psycopg[binary] is the documented quick install. On a platform where you cannot compile, a binary package is often the only option.

**What does failed-wheel-build-for-install mean?**

It is the error reference pip 25.2 and later print when one or more packages could not be built into wheels. The package names are listed under it. Earlier versions said Could not build wheels for X, which is required to install pyproject.toml-based projects, or Failed to build installable wheels for some pyproject.toml based projects.

**Which Python versions does Livops run?**

Python 3.10 to 3.14. Put the version in a .python-version file at the project root, for example 3.12, to match the version your packages have wheels for.

## Sources

1. [pip source — src/pip/_internal/exceptions/__init__.py (InstallWheelBuildError)](https://raw.githubusercontent.com/pypa/pip/main/src/pip/_internal/exceptions/__init__.py). Checked 23 November 2026.
2. [pip source — src/pip/_internal/exceptions/build.py (InstallationSubprocessError)](https://raw.githubusercontent.com/pypa/pip/main/src/pip/_internal/exceptions/build.py). Checked 23 November 2026.
3. [pip source — src/pip/_internal/operations/build/wheel.py](https://raw.githubusercontent.com/pypa/pip/main/src/pip/_internal/operations/build/wheel.py). Checked 23 November 2026.
4. [pip source — src/pip/_internal/utils/logging.py](https://raw.githubusercontent.com/pypa/pip/main/src/pip/_internal/utils/logging.py). Checked 23 November 2026.
5. [pip 24.0 source — src/pip/_internal/commands/install.py](https://raw.githubusercontent.com/pypa/pip/24.0/src/pip/_internal/commands/install.py). Checked 23 November 2026.
6. [pip 24.1 source — src/pip/_internal/commands/install.py](https://raw.githubusercontent.com/pypa/pip/24.1/src/pip/_internal/commands/install.py). Checked 23 November 2026.
7. [pip 25.2 source — src/pip/_internal/commands/install.py](https://raw.githubusercontent.com/pypa/pip/25.2/src/pip/_internal/commands/install.py). Checked 23 November 2026.
8. [Python Packaging User Guide — Package formats](https://packaging.python.org/en/latest/discussions/package-formats/). Checked 23 November 2026.
9. [Python Packaging User Guide — Platform compatibility tags](https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/). Checked 23 November 2026.
10. [pip docs — pip install](https://pip.pypa.io/en/stable/cli/pip_install/). Checked 23 November 2026.
11. [pip docs — Caching](https://pip.pypa.io/en/stable/topics/caching/). Checked 23 November 2026.
12. [pip docs — pip download](https://pip.pypa.io/en/stable/cli/pip_download/). Checked 23 November 2026.
13. [Psycopg 2 — Installation](https://www.psycopg.org/docs/install.html). Checked 23 November 2026.
14. [Psycopg 3 — Installation](https://www.psycopg.org/psycopg3/docs/basic/install.html). Checked 23 November 2026.
15. [cryptography — Installation](https://cryptography.io/en/latest/installation/). Checked 23 November 2026.
