Last updated: Apr 9, 2024
Reading timeยท15 min
To solve the error "Could not build wheels for X which use PEP 517 and cannot
be installed directly", run the pip install --upgrade pip
command to upgrade
your pip
version and rerun the pip install <package-name>
command.
ERROR: Failed building wheel for <package-name> Failed to build pycairo ERROR: Could not build wheels for <package-name> which use PEP 517 and cannot be installed directly ERROR: Could not build wheels for <package-name>, which is required to install pyproject.toml-based projects
Another common name for the same error is: "ERROR: Could not build wheels for
package-name
, which is required to install pyproject.toml-based projects".
The solution for the two errors is the same.
The most common cause of the error is having an outdated version of pip
.
pip
before installing the packageHere are the commands for upgrading pip
on all operating systems.
Which command works depends on your operating system and your version of Python.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --upgrade pip # ๐๏ธ If you don't have pip in your PATH environment variable python3 -m pip install --upgrade pip # ๐๏ธ If you have easy_install easy_install --upgrade pip # ๐๏ธ If you get a permissions error sudo easy_install --upgrade pip # ๐๏ธ If you get a permissions error when upgrading pip pip install --upgrade pip --user # ๐๏ธ Upgrade pip scoped to the current user (if you get a permissions error) python -m pip install --user --upgrade pip python3 -m pip install --user --upgrade pip # ๐๏ธ Installing directly from get-pip.py (MacOS and Linux) curl https://bootstrap.pypa.io/get-pip.py | python # ๐๏ธ If you get permissions issues curl https://bootstrap.pypa.io/get-pip.py | sudo python # ๐๏ธ Alternative for Ubuntu/Debian sudo apt-get update && apt-get upgrade python-pip # ๐๏ธ Alternative for Red Hat / CentOS / Fedora sudo yum install epel-release sudo yum install python-pip sudo yum update python-pip
Now that pip
is upgraded, try to run the pip install <package-name>
command.
pip install requests pip3 install requests python -m pip install requests python3 -m pip install requests
requests
with the actual name of the package you're trying to install.setuptools
and wheel
If the error is not resolved, upgrade the setuptools and wheel packages as well.
pip install --upgrade setuptools wheel pip3 install --upgrade setuptools wheel python3 -m pip install --upgrade setuptools wheel
Try to rerun the pip install
command after upgrading setuptools
and wheel
.
If that didn't help, try to run the pip install
command with the --upgrade
option.
pip install requests --upgrade pip3 install requests --upgrade python -m pip install requests --upgrade python3 -m pip install requests --upgrade
If the error is not resolved, try installing the package with the --no-cache-dir option to disable the cache.
pip install requests --no-cache-dir pip3 install requests --no-cache-dir
If that didn't help, use the --pre
option to include pre-release and
development versions of the package.
pip install requests --pre pip3 install requests --pre python -m pip install requests --pre python3 -m pip install requests --pre
The --pre
option makes it so pip
includes pre-release and development
versions of the package. By default pip
only finds stable versions.
wheel
available for your version of Python.If the error is not resolved, try running the pip install
command with the
--no-use-pep517
option.
pip install --no-use-pep517 requests pip3 install --no-use-pep517 requests python -m pip install --no-use-pep517 requests python3 -m pip install --no-use-pep517 requests
If that didn't help, try installing another version of the package.
You can check the available versions of a package by running the
pip install package==
command.
pip install requests==
The output contains a tuple of all of the versions of the package from the oldest to the most recent version.
Pick another version of the package and try installing it. Here is an example.
pip install requests==2.28.0 pip3 install requests==2.28.0
If that didn't help, try creating a virtual environment.
pip install
command with the virtual environment active.# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ Install the specific package in the virtual environment pip install requests
If the python3 -m venv venv
command doesn't work, try the following 2
commands:
python -m venv venv
py -m venv venv
Make sure to use the correct command to activate your virtual environment depending on your operating system and your shell.
Your virtual environment will use the version of Python that was used to create it.
If none of the suggestions helped, try running the pip install
command in
verbose mode.
pip install requests -vvv pip3 install requests -vvv python -m pip install requests -vvv
The -v
option stands for verbose mode and can be used up to 3 times.
When the pip install
command is run in verbose mode, the command shows more
output and how the error occurred.
The error is sometimes caused when the package you are trying to install doesn't
have available wheels
for your version of Python.
You can check your Python version with the python --version
command.
python --version
You can check if a package has wheels available for a specific Python version in
the Download files section of the
package's pypi
page.
cp310
in the name of a file under "Built Distributions" means Python version 3.10 is supported for the specific operating system.If the .whl
files are not available for your version of Python, you can
download an older version.
You can download a specific Python version that is supported by the package if the package doesn't support the latest Python version.
Different versions are available in the "Looking for a specific release" table.
Make sure to tick the following options if you get prompted:
Some packages require you to have certain applications installed before you are
able to pip install
the package.
Here are some examples.
The following error occurs when you install python-ldap
without having the
prerequisites installed.
ERROR: Failed building wheel for python-ldap Failed to build python-ldap ERROR: Could not build wheels for python-ldap, which is required to install pyproject.toml-based projects
Installing the prerequisites for python-ldap
.
# ๐๏ธ Debian (Ubuntu) sudo apt-get install build-essential python3-dev \ libldap2-dev libsasl2-dev slapd ldap-utils tox \ lcov valgrind # ๐๏ธ RedHat/CentOS yum groupinstall "Development tools" yum install openldap-devel python-devel # ๐๏ธ Fedora dnf install "@C Development Tools and Libraries" openldap-devel \ python3-devel python3-tox \ lcov clang-analyzer valgrind # ๐๏ธ Alpine apk add build-base openldap-dev python3-dev
You have to run the pip install python-ldap
command after installing the
prerequisites.
pip install python-ldap pip3 install python-ldap
The following error occurs when you install PyAudio
without having the
prerequisites installed.
ERROR: Failed building wheel for pyaudio Failed to build pyaudio ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
First, if you are on Linux, make sure you have all the requirements of
pyaudio
.
sudo apt install build-essential portaudio19-dev python3.10-dev pip install pyaudio
portaudio
is a prerequisite of pyaudio
, so if portaudio
is missing, the error is raised.If you are on macOS, try using brew
to install the package.
brew install portaudio brew link --overwrite portaudio pip install pyaudio
If you are on macOS, you also have to install portaudio
before installing
pyaudio
.
You can read more about the prerequisite in the pypi page of pyaudio.
If you are on Windows, the python -m pip install pyaudio
command installs the
precompiled PyAudio library with PortAudio included.
If you use anaconda, try using conda
.
conda install -c anaconda pyaudio
After you have the prerequisites installed, run the installation command.
pip install PyAudio pip3 install PyAudio
The following error occurs when you install pycocotools
without having the
prerequisites installed.
ERROR: Failed building wheel for pycocotools Failed to build pycocotools ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects
If you use anaconda, the first thing you should try is to run the following two commands.
conda install -c conda-forge pycocotools conda install -c esri pycocotools
If you use Windows, install the pycocotools-windows
package instead.
pip install pycocotools-windows pip3 install pycocotools-windows python -m pip install pycocotools-windows python3 -m pip install pycocotools-windows
The following error occurs when you install pycocotools
without having the
prerequisites installed.
ERROR: Failed building wheel for cx_Oracle Failed to build cx_Oracle ERROR: Could not build wheels for cx_Oracle, which is required to install pyproject.toml-based projects
First, make sure to install gcc
and python3-dev
if you are on Linux.
# ๐๏ธ For Debian (Ubuntu) sudo apt-get install gcc python3-dev # ๐๏ธ For RedHad / CentOS sudo yum install gcc python3-devel
After you install the prerequisites, run the following command to install cx-Oracle.
pip install cx-Oracle --upgrade pip3 install cx-Oracle --upgrade
The following error occurs when installing scikit-learn.
ERROR: Failed building wheel for scikit-learn Failed to build scikit-learn ERROR: Could not build wheels for scikit-learn, which is required to install pyproject.toml-based projects
If you use anaconda, try installing the package using conda
.
conda install -c anaconda scikit-learn conda install -c conda-forge scikit-learn pip install scikit-learn pip3 install scikit-learn
The following error occurs when installing opencv-python.
ERROR: Failed building wheel for opencv-python Failed to build opencv-python ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
After you update your version of pip
, run the following command.
pip install opencv-python pip3 install opencv-python python -m pip install opencv-python python3 -m pip install opencv-python # ๐๏ธ For Anaconda conda install -c conda-forge opencv # ๐๏ธ Alternative for Debian (Ubuntu) sudo apt-get install python-opencv
The following error occurs when installing numpy
.
ERROR: Failed building wheel for numpy Failed to build numpy ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly
After you update your version of pip
, run the following command.
pip install numpy pip3 install numpy python -m pip install numpy python3 -m pip install numpy # ๐๏ธ For Anaconda conda install -c anaconda numpy
The following error occurs when installing cryptography.
ERROR: Failed building wheel for cryptography Running setup.py clean for cryptography Failed to build cryptography ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
After you update your version of pip
, run the following command.
pip install cryptography pip3 install cryptography python -m pip install cryptography python3 -m pip install cryptography # ๐๏ธ For Anaconda conda install -c anaconda cryptography
The following error occurs when installing psutil.
ERROR: Failed building wheel for psutil Failed to build psutil ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects
After you update your version of pip
, run the following command.
pip install psutil pip3 install psutil python -m pip install psutil python3 -m pip install psutil # ๐๏ธ For Anaconda conda install -c conda-forge psutil
As the installation page of psutil notes, pre-compiled wheels are available for Linux, Windows and macOS, so you don't have to install a C compiler.
Running the pip install psutil
command should be sufficient.
If that doesn't work, try installing from sources if you are on Linux.
# ๐๏ธ For Debian (Ubuntu) sudo apt-get install gcc python3-dev pip install --no-binary :all: psutil # ๐๏ธ For RedHad / CentOS sudo yum install gcc python3-devel pip install --no-binary :all: psutil
The following error occurs when installing gevent
.
Failed to build gevent ERROR: Could not build wheels for gevent, which is required to install pyproject.toml-based projects
First, make sure to install the prerequisites.
# ๐๏ธ For Debian (Ubuntu) sudo apt-get install python3.10-dev linux-headers-virtual make gcc libtool # ๐๏ธ For Fedora yum install python3-devel gcc kernel-devel kernel-headers make diffutils file # ๐๏ธ For Alpine Linux apk add --virtual build-deps file make gcc musl-dev libffi-dev
You can read more about the prerequisites in the installation section of gevent's pypi page.
After you update your version of pip
, use the following command to install
gevent
.
pip install gevent pip3 install gevent python -m pip install gevent python3 -m pip install gevent # ๐๏ธ For Anaconda conda install -c anaconda gevent
The following error occurs when installing pycairo
.
ERROR: Failed building wheel for pycairo Failed to build pycairo ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
The first thing you should try is to install the dependencies.
sudo apt install libcairo2-dev libcairo2 pkg-config sox ffmpeg pip install pycairo # ๐๏ธ If you use manim animation engine pip install manimlib pip install manimce
After updating your version of pip
, use the following command to install
pycairo
.
pip install pycairo pip3 install pycairo python -m pip install pycairo python3 -m pip install pycairo
The following error occurs when installing pycuda
.
ERROR: Failed building wheel for pycuda Failed to build pycuda ERROR: Could not build wheels for pycuda, which is required to install pyproject.toml-based projects
First, if you are on Linux, install the prerequisites.
# ๐๏ธ Debian (Ubuntu) sudo apt-get install python3-dev # ๐๏ธ CentOS, RHEL sudo yum install python3-devel # ๐๏ธ Fedora sudo dnf install python3-devel # ๐๏ธ openSUSE sudo zypper in python3-devel # ๐๏ธ Alpine sudo apk add python3-dev # ๐๏ธ Cygwin apt-cyg install python3-devel
After updating your version of pip
, use the following command to install
pycuda
.
pip install pycuda pip3 install pycuda python -m pip install pycuda python3 -m pip install pycuda # ๐๏ธ For Anaconda conda install -c conda-forge pycuda
The following error occurs when installing tokenizers
.
ERROR: Failed building wheel for tokenizers Failed to build tokenizers ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects
First, make sure you have a Rust compiler installed.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh export PATH="$HOME/.cargo/bin:$PATH" source $HOME/.cargo/env pip install tokenizers
You can read more about the prerequisites in the pypi page of tokenizers.
After updating your version of pip
, use the following command to install
tokenizers
.
pip install tokenizers pip3 install tokenizers python -m pip install tokenizers python3 -m pip install tokenizers # ๐๏ธ For Anaconda conda install -c conda-forge tokenizers
The following error occurs when installing discord.py
.
ERROR: Failed building wheel for multidict Failed to build yarl multidict ERROR: Could not build wheels for yarl, multidict which use PEP 517 and cannot be installed directly
Note that the discord.py module requires Python v3.8+.
After updating your version of pip
, run the following command to install
discord.py
.
pip install discord.py pip3 install discord.py python -m pip install discord.py python3 -m pip install discord.py # ๐๏ธ For Anaconda conda install -c conda-forge discord.py
The following error occurs when installing xmlsec
in Python.
ERROR: Failed building wheel for xmlsec Failed to build xmlsec ERROR: Could not build wheels for xmlsec, which is required to install pyproject.toml-based projects
First, install the prerequisites for your operating system.
# ๐๏ธ for macOS brew install libxml2 libxmlsec1 pkg-config # ๐๏ธ for Windows pip install xmlsec --no-binary=xmlsec # ๐๏ธ for Debian (Ubuntu) sudo apt-get install pkg-config libxml2-dev libxmlsec1 libxmlsec1-dev libxmlsec1-openssl # ๐๏ธ for CentOS yum install libxml2-devel xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel # ๐๏ธ for Fedora dnf install libxml2-devel xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel # ๐๏ธ for Alpine apk add build-base libressl libffi-dev libressl-dev libxslt-dev libxml2-dev xmlsec-dev xmlsec
xmlsec
depends on that are not included in the module.You can read more about the prerequisites in the pypi page of xmlsec.
If you are on Windows, running the pip install xmlsec --no-binary=xmlsec
command should be sufficient.
After updating your version of pip
, run the following command to install
xmlsec
.
pip install xmlsec pip3 install xmlsec python -m pip install xmlsec python3 -m pip install xmlsec # ๐๏ธ For Anaconda conda install -c conda-forge xmlsec
The following error occurs when installing bcrypt
in Python.
ERROR: Failed building wheel for bcrypt ERROR: Could not build wheels for bcrypt which use PEP 517 and cannot be installed directly
First, if you are on Linux, make sure to install the prerequisites.
# ๐๏ธ for Debian (Ubuntu) sudo apt-get install build-essential cargo # ๐๏ธ for Fedora and RHEL-derivatives sudo yum install gcc cargo # ๐๏ธ for Alpine apk add --update musl-dev gcc cargo
You can read more about the prerequisites in the pypi page of bcrypt.
After updating your version of pip
, use the following command to install
bcrypt
.
pip install bcrypt pip3 install bcrypt python -m pip install bcrypt python3 -m pip install bcrypt # ๐๏ธ using Anaconda conda install -c anaconda bcrypt
The following error occurs when installing hdbscan
in Python.
ERROR: Failed building wheel for hdbscan ERROR: Could not build wheels for hdbscan which use PEP 517 and cannot be installed directly
If you use anaconda, try installing the package with the following command.
conda install -c conda-forge hdbscan
You should also install the python3.X-dev
package because packages that
compile C Python modules during installation require the python-dev
package.
sudo apt-get install python3.10-dev
After updating your version of pip
, use the following command to install
hdbscan
.
pip install hdbscan --upgrade pip3 install hdbscan --upgrade python -m pip install hdbscan --upgrade python3 -m pip install hdbscan --upgrade
The following error occurs when installing PyNaCl
in Python.
ERROR: Failed building wheel for PyNaCl ERROR: Could not build wheels for PyNaCl which use PEP 517 and cannot be installed directly
After updating your version of pip
, use the following command to install
PyNaCl
.
pip install PyNaCl pip3 install PyNaCl python -m pip install PyNaCl python3 -m pip install PyNaCl # ๐๏ธ For Anaconda conda install -c conda-forge pynacl
The following error occurs when installing onnx
in Python.
ERROR: Failed building wheel for onnx Failed to build onnx ERROR: Could not build wheels for onnx, which is required to install pyproject.toml-based projects
First, if you are on Linux, install the prerequisites.
sudo apt-get install python3-pip python3-dev libprotobuf-dev protobuf-compiler
If you use Anaconda, you can also try installing the package using
conda-forge
.
conda install -c conda-forge numpy protobuf libprotobuf conda install -c conda-forge onnx
After updating your version of pip
, use the following command to install
onnx
.
pip install numpy protobuf pip install onnx pip3 install numpy protobuf pip3 install onnx python -m pip install numpy protobuf python -m pip install onnx python3 -m pip install numpy protobuf python3 -m pip install onnx # ๐๏ธ For Anaconda conda install -c conda-forge numpy protobuf libprotobuf conda install -c conda-forge onnx
The following error occurs when installing spacy in Python.
ERROR: Failed building wheel for spacy Failed to build spacy ERROR: Could not build wheels for spacy, which is required to install pyproject.toml-based projects
First, if you are on Linux, install the prerequisites.
sudo apt-get install build-essential python-dev git
After updating your version of pip
, use the following command to install
spacy
.
# ๐๏ธ In a virtual environment or using Python 2 pip install -U spacy python -m spacy download en_core_web_sm # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install -U spacy python -m spacy download en_core_web_sm # ๐๏ธ If you get a permissions error sudo pip3 install -U spacy python -m spacy download en_core_web_sm # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install -U spacy python -m spacy download en_core_web_sm # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install -U spacy python3 -m spacy download en_core_web_sm # ๐๏ธ For Anaconda conda install -c conda-forge spacy python -m spacy download en_core_web_sm
The following error occurs when installing sip
in Python.
ERROR: Failed building wheel for sip Failed to build sip ERROR: Could not build wheels for sip, which is required to install pyproject.toml-based projects
After updating your version of pip
, use the following command to install
sip
.
pip install sip pip3 install sip python -m pip install sip python3 -m pip install sip # ๐๏ธ For Anaconda conda install -c anaconda sip
The following error occurs when installing scipy
in Python.
ERROR: Failed building wheel for scipy ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
After updating your version of pip
, use the following command to install
scipy.
pip install scipy pip3 install scipy python -m pip install scipy python3 -m pip install scipy # ๐๏ธ alternative for Debian (Ubuntu) sudo apt-get install python3-scipy # ๐๏ธ Alternative for Fedora sudo dnf install python3-scipy # ๐๏ธ Alternative for macOS brew install scipy
To solve the error "Could not build wheels for X which use PEP 517 and cannot
be installed directly", run the pip install --upgrade pip
command to upgrade
your pip
version and rerun the pip install <package-name>
command.