pip: Getting requirements to build wheel did not run successfully — how to fix it
pip found no wheel for the package, so it started building one from source, and the package's own build script failed at the first step, while pip was asking it which build tools it needs. The real error is in the lines inside pip's box: usually a module setup.py imports but never declared (numpy, Cython, pkg_resources), a release too old for your Python, or a missing program such as pg_config. Move to a release with a wheel for your Python, or pin the Python it supports.
By Livops team, the people who build and run LivopsUpdated
This is what pip prints when the step fails, here installing psycopg2 on a machine without PostgreSQL’s client tools (pip 26.0.1, shortened; the same messages are in pip 26.3’s source[1][2][3]):
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [34 lines of output]
...
running egg_info
...
Error: pg_config executable not found.
...
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'psycopg2' when getting requirements to build wheel
pip 25.2 and earlier end differently: the box is printed a second time, with ╰─> See above for output. in place of the output[4]. The last line, Failed to build '…' when getting requirements to build wheel, comes from pip 25.3 and later[3]. Same failure, same fix.
This page explains what pip is doing at that moment, how to find the real error in the output, the causes from the most common, and how it differs from the better-known Failed building wheel. Nothing here is specific to Livops until the last section.
What does the error mean?
When there is no wheel that fits your Python and platform, pip builds one from the source distribution (sdist). It does that in steps, and prints each one[1][10][11]:
- Installing build dependencies — the packages listed in the project’s
pyproject.tomlunder[build-system] requires, installed into a temporary, isolated environment[6]. - Getting requirements to build wheel — pip calls the build backend’s
get_requires_for_build_wheelhook[1]. PEP 517 defines it: the backend returns any extra packages it needs to build a wheel, beyond those inpyproject.toml[5]. - Preparing metadata (pyproject.toml).
- Building wheel for … (pyproject.toml) — the actual build, with the compiler if there is one.
Your error is step 2. For the setuptools backend, answering that question means running the project’s setup.py; the traceback in your output shows it, ending in setuptools’ run_setup. A project with a setup.py and no [build-system] table gets setuptools as its backend, setuptools.build_meta:__legacy__ with setuptools>=40.8.0[6]. So anything setup.py does at the top — an import, a call to pg_config, a version check — runs now, before any compiling. If it fails, the step fails.
And it runs in the isolated environment from step 1. PEP 517 says this hook runs in an environment containing only the bootstrap requirements from pyproject.toml[5], and pip keeps build requirements apart from your runtime environment on purpose[6]. A module you installed yourself is not there.
Before pip 25.3 some projects with only a setup.py went through a legacy path, where the same failure was labelled python setup.py egg_info did not run successfully[9]; pip 25.3 made --use-pep517 always on[8].
Read the real error first
pip’s own lines are the same for every package. The answer is between [N lines of output] and [end of output]: the output of the build script, which pip collects and prints inside the box[2]. Scroll to the last line of the traceback there. A demonstration package whose setup.py starts with import numpy ends like this:
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
[end of output]
What that last line says decides the fix:
| Last line inside the box | Cause below |
|---|---|
ModuleNotFoundError: No module named 'numpy' (or Cython, torch) |
1 |
ModuleNotFoundError: No module named 'pkg_resources' |
2 |
AttributeError: module 'pkgutil' has no attribute 'ImpImporter' |
3 |
No module named 'distutils' or 'imp' |
3 |
Error: pg_config executable not found. or another missing program |
4 |
Causes, most common first
1. setup.py imports a package it never declared
Older projects write import numpy (for numpy.get_include()) or from Cython.Build import cythonize at the top of setup.py, and do not list numpy or Cython in [build-system] requires. In the isolated build environment those modules are not installed[5][6], so the import fails. Installing numpy into your own environment first does not help, for the same reason.
Fixes, in the order to try them:
- Install a release that has a wheel for your Python. Then pip downloads the wheel and never runs
setup.py. Pin with>=to a recent release rather than an old==. - Pin the Python the release supports (cause 3), if you cannot move the package.
- Last resort: turn isolation off.
--no-build-isolationbuilds in your own environment; you must have installed every build dependency yourself, as pip does not manage them with this flag[6][7]:
pip install numpy cython setuptools wheel
pip install --no-build-isolation somepackage==1.2.3
2. setup.py imports pkg_resources
pkg_resources used to come with setuptools. Setuptools 82.0.0, released on 8 February 2026, removed it[12]. The isolated environment gets a current setuptools[6], so an old setup.py with import pkg_resources now fails at this step, whatever setuptools you have installed yourself. A newer release of the package is the fix; failing that, pip 25.3 and later accept a build constraints file that applies only to isolated build environments[22]:
echo 'setuptools<82' > build-constraints.txt
pip install --build-constraint build-constraints.txt -r requirements.txt
The same option can be set with the PIP_BUILD_CONSTRAINT environment variable[7]. The details, and the runtime side of the same error, are in No module named ‘pkg_resources’.
3. The release is older than your Python
An == pin names a release that has wheels only for the Pythons that existed then. On a newer Python pip finds only the sdist and runs its old setup.py, which may use something the newer Python removed. Python 3.12 removed distutils, the imp module, and pkgutil.ImpImporter[13]; Python 3.13 removed 19 more legacy modules and lib2to3[14].
NumPy is the well-known case. Version 1.25.2 publishes wheels for CPython 3.9, 3.10 and 3.11 only[17], and its build requirements pin setuptools==59.2.0[16]. The pkg_resources in setuptools 59.2.0 refers to pkgutil.ImpImporter[18], which Python 3.12 no longer has[13]. So numpy==1.25.2 on Python 3.12 is built from source, and the build backend fails as it loads. NumPy 1.26.0 is the first release with Python 3.12 support[15]:
numpy>=1.26 # instead of numpy==1.25.2, on Python 3.12
Fix: raise the pin to a release that ships a wheel for your Python, or pin the Python version the release supports. For the module errors on their own, see No module named ‘distutils’ and No module named ‘imp’.
4. A system program or header is missing
Some setup.py files look for system tools while they are being asked for requirements. psycopg2 runs pg_config to find PostgreSQL’s client library, and stops with Error: pg_config executable not found. if it is not on the PATH[19]; that is the output at the top of this page. Its docs list what a source build needs: a C compiler, the Python headers, the libpq headers and pg_config[20]. Other packages fail the same way on a missing pkg-config, a library, or a header.
Fix: use a variant that ships wheels (psycopg2-binary, or psycopg[binary] for Psycopg 3), or install the system packages in a Dockerfile. The psycopg2 case step by step: pg_config executable not found.
Getting requirements vs Failed building wheel
Both errors start the same way — no wheel fit, so pip builds from source — and they fail at different steps:
| Getting requirements to build wheel | Failed building wheel | |
|---|---|---|
| Step | get_requires_for_build_wheel, before the build[1][5] |
build_wheel, the build itself[11] |
| What fails | Python code in setup.py: an import, a version check, a tool lookup |
Usually the compiler: a missing header, compiler, or Rust toolchain |
| pip’s last line (25.3+) | Failed to build '…' when getting requirements to build wheel[3] |
error: failed-wheel-build-for-install |
A compiler would not fix most of the first kind. The first fix for both is the same: a release, or a variant, that ships a wheel for your Python. The second error has its own page: Failed building wheel / failed-wheel-build-for-install.
Never build from source by accident
Tell pip to refuse sdists, and a package without a matching wheel fails at once with a clear message instead of a traceback from its setup.py. --only-binary :all: disables source packages; --prefer-binary picks a wheel over a newer sdist[7]:
pip install --only-binary :all: -r requirements.txt
Both options can also go on their own line inside requirements.txt[21], so they apply wherever the file is installed:
--prefer-binary
--only-binary numpy
numpy>=1.26
psycopg2-binary>=2.9
To check before a deploy, run the same install in a clean container with the Python you deploy on:
docker run --rm -v "$PWD":/app -w /app python:3.12-slim \
pip install --only-binary :all: -r requirements.txt
A package that has no wheel for that Python is named in the error. Change its pin, or its variant, until the command passes.
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. See Install failed. -
Set the Python version in a file. Livops runs Python 3.10 to 3.14 and reads
.python-versionandruntime.txt. A.python-versionat the project root with one line pins it — the fix for cause 3 when you cannot move the package:3.12 -
A second try with a compiler. When a Python package compiles on install (
mysqlclient,psycopg2and the like), Livops retries the install in an image with a compiler. That helps a build that needs a compiler; it does not help asetup.pythat imports a module it never declared, so for causes 1 to 3 change the pin. For psycopg2 the documented way out is the variant that needs no compiling:psycopg2-binary # instead of psycopg2 PyMySQL # instead of mysqlclient -
Ten minutes per build. A large package built from source can run past the ten-minute limit and stop as
timed_out. A wheel installs in seconds. -
A Dockerfile, if you need system packages. A
Dockerfilecan install them, for examplelibpq-dev. By default theDockerfileis used when no framework was recognised;"builder": "dockerfile"inlivops.json, read when the project is created, makes it the one that builds. See Frameworks. -
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 Python web app costs 39 credits a month; a bot, worker or cron job 19.
Questions
What does Getting requirements to build wheel mean?
It is the step where pip, about to build a package from source, asks the package's build backend which extra packages the build needs. That is the PEP 517 hook get_requires_for_build_wheel. For a setuptools project it runs setup.py, so any import or check at the top of setup.py runs here, before anything is compiled.
Where is the real error?
Inside pip's box, in the lines between [N lines of output] and [end of output]. The last line of the traceback there names it, for example ModuleNotFoundError: No module named 'numpy'. Everything under the box is pip's summary and is the same for every package.
How is it different from Failed building wheel?
Getting requirements to build wheel fails before the compile starts, usually in Python code in setup.py. Failed building wheel fails later, in the build_wheel step, usually in a compiler. The causes overlap, the cure is often the same: install a release that ships a wheel for your Python.
Why does pip install numpy separately and still fail?
pip builds each package in an isolated environment that contains only the package's declared build dependencies, not what you installed. A setup.py that imports numpy without declaring it fails there. Install a release with a wheel, or, as a last resort, install the build dependencies yourself and pass --no-build-isolation.
Is this a bug in pip?
Almost never. pip's note says the error originates from a subprocess and is likely not a problem with pip. pip only ran the package's build script; the script failed.
Why did it start after upgrading Python?
A pinned release has wheels only for the Python versions that existed when it came out. On a newer Python pip falls back to the source package, and its old setup.py may rely on something the new Python removed, such as distutils, imp or pkgutil.ImpImporter in Python 3.12.
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
- pip 26.3 source — src/pip/_internal/distributions/sdist.py (raw.githubusercontent.com). Checked .
- pip 26.3 source — src/pip/_internal/exceptions/build.py (InstallationSubprocessError) (raw.githubusercontent.com). Checked .
- pip 26.3 source — src/pip/_internal/exceptions/__init__.py (FailedToPrepareCandidate) (raw.githubusercontent.com). Checked .
- pip 25.2 source — src/pip/_internal/exceptions.py (raw.githubusercontent.com). Checked .
- PEP 517 — A build-system independent format for source trees (peps.python.org). Checked .
- pip docs — Build System Interface (pip.pypa.io). Checked .
- pip docs — pip install (pip.pypa.io). Checked .
- pip docs — Release notes (pip.pypa.io). Checked .
- pip 25.2 source — src/pip/_internal/operations/build/metadata_legacy.py (raw.githubusercontent.com). Checked .
- pip 26.3 source — src/pip/_internal/operations/build/metadata.py (raw.githubusercontent.com). Checked .
- pip 26.3 source — src/pip/_internal/operations/build/wheel.py (raw.githubusercontent.com). Checked .
- Setuptools docs — History (v82.0.0) (setuptools.pypa.io). Checked .
- Python docs — What's New In Python 3.12 (docs.python.org). Checked .
- Python docs — What's New In Python 3.13 (docs.python.org). Checked .
- NumPy 1.26.0 release notes (numpy.org). Checked .
- NumPy 1.25.2 source — pyproject.toml (raw.githubusercontent.com). Checked .
- PyPI JSON API — numpy 1.25.2 files (pypi.org). Checked .
- Setuptools 59.2.0 source — pkg_resources/__init__.py (raw.githubusercontent.com). Checked .
- psycopg2 2.9.10 source — setup.py (raw.githubusercontent.com). Checked .
- Psycopg 2 — Installation (psycopg.org). Checked .
- pip docs — Requirements File Format (pip.pypa.io). Checked .
- pip docs — User Guide (Build Constraints) (pip.pypa.io). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your Python appRelated
- pip: Failed building wheel / failed-wheel-build-for-install — how to fix itpip 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.
- ModuleNotFoundError: No module named 'pkg_resources': how to fix itModuleNotFoundError: No module named 'pkg_resources' means code imported pkg_resources, which is part of setuptools, not the standard library. Python 3.12 stopped pre-installing setuptools in new virtual environments, and setuptools 82.0.0 removed pkg_resources altogether, so installing the latest setuptools no longer brings it back. Upgrade the package that imports it, move your own code to importlib.metadata and importlib.resources, or pin setuptools<82 as a stopgap.
- Error: pg_config executable not found (psycopg2): how to fix itError: pg_config executable not found, followed by Failed building wheel for psycopg2, means pip is compiling psycopg2 from source and the machine has no PostgreSQL client headers or pg_config. Switch to a package that needs no compiling, psycopg2-binary or psycopg[binary] for Psycopg 3, or install libpq-dev and a C compiler where the build runs.
- ModuleNotFoundError: No module named 'distutils' on Python 3.12+: how to fix itModuleNotFoundError: No module named 'distutils' means code running on Python 3.12 or later imported distutils, which PEP 632 removed from the standard library in 3.12. It is usually an old package pinned in requirements.txt, built from source or imported at runtime. Upgrade that package to a release that supports your Python, install setuptools for code that still imports distutils, or pin Python 3.11 with a .python-version file while you upgrade.
- ModuleNotFoundError: No module named 'imp' on Python 3.12+: how to fix itModuleNotFoundError: No module named 'imp' means code running on Python 3.12 or later imported imp, which was deprecated since Python 3.4 and removed from the standard library in 3.12. It is almost always an old release of a library, or old code of your own. Upgrade that library, replace the imp calls with their importlib equivalents, or pin Python 3.11 with a .python-version file while you upgrade.
- pip: Could not find a version that satisfies the requirement / No matching distribution found — how to fix itERROR: Could not find a version that satisfies the requirement X (from versions: none), followed by No matching distribution found for X, means pip searched the package index and found no release of X it can install here. The name is wrong (often the import name instead of the package name), the pinned version does not exist, every release needs a different Python, no file fits your platform, or pip is looking at the wrong index or cannot reach it. The versions list in the message tells you which.
- ERROR: Could not install packages due to an OSError (pip): Errno 13, 28 and 2 fixedERROR: Could not install packages due to an OSError means the operating system refused a file operation while pip was installing, and the text after the colon says which: [Errno 13] Permission denied is a folder pip may not write to, usually a system Python or a root-owned environment; [Errno 28] No space left on device is a full disk or temp folder; [Errno 2] No such file or directory on Windows is often a path over 260 characters. Install into a virtual environment, free space or point TMPDIR elsewhere, and enable long paths; never sudo pip.