Last modified: Oct 01, 2026

Fix "Could Not Build Wheels" pip Error

You run a simple pip install command. Then the terminal explodes with red text. One line reads: "Could not build wheels for..."

This error stops your Python project cold. It is common. It is also fixable.

This guide explains why the error happens. Then it shows you exactly how to solve it.

What Does "Could Not Build Wheels" Mean?

Python packages come in two forms. One is a source distribution. The other is a pre-built wheel.

A wheel is a ready-to-install package. It needs no compilation. Pip installs it in seconds.

A source distribution contains raw code. Pip must compile it on your machine. This requires compilers and system libraries.

When pip says "Could not build wheels", it means the compilation failed. Your system lacks a tool or a library.

Why Does This Error Happen?

Several causes trigger this error. Here are the most common ones.

Missing compilers. Many packages contain C or C++ code. Your system needs a C compiler to build them.

Missing system libraries. Some packages depend on external libraries. These include OpenSSL, libffi, or zlib.

Outdated pip. Old pip versions struggle with modern wheels. They may fall back to source builds.

Missing Python headers. Building extensions requires Python development files.

Incompatible Python version. Some packages do not support your Python version yet.

Step 1: Read the Full Error Message

Do not panic. Read the whole output first. The real cause hides near the bottom.

Look for lines mentioning missing headers or failed commands. They point to the real problem.


# Example error output
ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects
error: command 'gcc' failed with exit status 1
fatal error: openssl/opensslv.h: No such file or directory

In this example, the missing file is an OpenSSL header. That tells you exactly what to install.

Step 2: Upgrade pip, setuptools, and wheel

An outdated pip is a frequent culprit. Newer pip versions find pre-built wheels more often.

Run this command first. It solves many cases instantly.


python -m pip install --upgrade pip setuptools wheel

Then retry your original install. If the error persists, move to the next step.

Step 3: Install Build Tools

You need a compiler. The install command depends on your operating system.

On Ubuntu or Debian


sudo apt update
sudo apt install build-essential python3-dev

On Fedora or CentOS


sudo dnf groupinstall "Development Tools"
sudo dnf install python3-devel

On macOS

Install the Xcode command line tools. This gives you the clang compiler.


xcode-select --install

On Windows

Install the Microsoft C++ Build Tools. Download them from the official Microsoft site.

During setup, select "Desktop development with C++". Then restart your terminal.

Step 4: Install Missing System Libraries

Some packages need extra libraries. Here are common examples.

For cryptography, you need OpenSSL headers.


sudo apt install libssl-dev libffi-dev

For Pillow, you need image libraries.


sudo apt install libjpeg-dev zlib1g-dev

For lxml, install the XML libraries.


sudo apt install libxml2-dev libxslt1-dev

After installing, retry the pip command.

Step 5: Use Pre-built Wheels Only

You can force pip to skip source builds. Use the --only-binary flag.


pip install cryptography --only-binary :all:

This tells pip to use only wheels. If no wheel exists, pip fails fast. But it avoids long compile errors.

This trick works well when a wheel exists for your platform.

Step 6: Check Your Python Version

Your Python version may be too new or too old. Some packages lag behind.

Run this command to check your version.


import sys
print(sys.version)
# Output: 3.12.1 (main, Dec  7 2023, 12:00:00) [GCC 11.4.0]

If your version is very new, try an older Python. Tools like pyenv make this easy.

Step 7: Use a Virtual Environment

Always work inside a virtual environment. It keeps your project clean.

It also avoids permission problems. Those problems often cause build failures.


python -m venv myenv
source myenv/bin/activate
pip install your-package

On Windows, activate with this command instead.


myenv\Scripts\activate

Step 8: Try a Different Package Version

Sometimes the latest version is broken. An older release may ship a working wheel.


pip install package-name==1.2.3

Check the package page for available versions. Pick one with a wheel for your platform.

Quick Troubleshooting Checklist

Use this list to debug fast.

1. Upgrade pip, setuptools, and wheel.
2. Install build tools for your OS.
3. Install missing system libraries.
4. Use --only-binary :all: to skip source builds.
5. Check your Python version.
6. Use a virtual environment.
7. Try an older package version.

Conclusion

The "Could not build wheels" error looks scary. But it is just a missing tool or library.

Start by reading the full error. It usually names the missing piece.

Then upgrade pip. Install build tools. Add the missing system libraries.

Most users fix this error in minutes. Follow the steps above in order. One of them will solve your problem.

Once fixed, your installs run smoothly. You can focus on writing code again.