ERROR: Failed building wheel for X / Microsoft Visual C++ 14.0 or greater is required
pip found no prebuilt package for your platform and tried to compile from source, which failed. Upgrade pip first, pick versions with wheels, and only install a compiler as the last resort.
Updated
The error
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for lxml Failed to build lxml ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects
On Linux the compiler line differs (gcc errors, missing headers like Python.h), and legacy packages show python setup.py egg_info did not run successfully — same disease.
What it means
A wheel is a prebuilt, ready-to-install package. When no wheel exists for your exact Python version and platform, pip downloads source code and compiles it on your machine — which requires a C/C++ toolchain most machines lack. The compile failed. The important insight: needing to compile at all is usually the real problem, because popular packages publish wheels for every mainstream platform.
Why it happens
Wheels are built per Python version. The most common trigger is a too-new Python: in the months after a Python release, many packages have no wheels for it yet, so pip falls back to source. Other triggers: an old pip that cannot recognise modern wheel formats, a package version so old it predates wheels for your platform, or a 32-bit Python. Least often, the package genuinely has no wheels and compiling is expected.
How to fix it
1. Upgrade pip, setuptools and wheel first. Old pip mis-selects or misses wheels; this one line resolves a surprising share of cases.
python -m pip install --upgrade pip setuptools wheel2. Scroll up and read the first error line. The wheel failure is the end of the story; the beginning names the cause — a missing compiler, a missing header, or a version-compatibility complaint from the build script. Fixes differ accordingly.
3. Check whether your Python is the problem.
python --versionOn a Python released in the last few months, try the package's newest version (older versions rarely gain new wheels), or use the previous Python minor version, where wheel coverage is complete. Version pins from old tutorials — numpy==1.19.5 on Python 3.12 — force source builds that can never succeed; unpin and take a current release.
4. On Windows, if you genuinely must compile, install the build tools. Download "Microsoft C++ Build Tools", select the "Desktop development with C++" workload, restart the terminal. This is legitimate for niche packages without Windows wheels — but exhaust fixes 1-3 first, and consider whether conda has a prebuilt package instead:
conda install -c conda-forge thepackage5. On Linux, install the toolchain and Python headers when compiling is intended.
sudo apt install build-essential python3-devHow to prevent it
Stay one step behind the newest Python for ML work — the wheel ecosystem needs a little time after each release. Keep pip current in every environment. When a pip install starts printing compiler output for a mainstream package, stop and ask why, rather than chasing the compile errors.
Related errors
- Could not find a version that satisfies the requirement — the neighbouring symptom of the same wheel-coverage gaps
- error: externally-managed-environment
- OSError: WinError 126 — Error loading fbgemm.dll — Windows toolchain trouble after install
- ResolutionImpossible: conflicting dependencies