Last updated: Apr 9, 2024
Reading time·5 min
To solve the "Python setup.py bdist_wheel did not run successfully" error, run
the pip install cmake
command and make sure you have the wheel
, setuptools
and pip
packages installed and upgraded.
× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [138 lines of output] running bdist_wheel
cmake
moduleThe first thing you should do is install cmake.
pip install cmake pip3 install cmake # 👇️ If you don't have pip in your PATH environment variable python -m pip install cmake python3 -m pip install cmake
The cmake
package is used to control the software compilation process.
wheel
installedThe next thing you should do is make sure you have wheel
installed.
If you are on Debian (Ubuntu), install the prerequisites first.
sudo apt-get install gcc libpq-dev -y sudo apt-get install python-dev python-pip -y sudo apt-get install python3-dev python3-pip python3-venv python3-wheel -y
Run the following command to install wheel and setuptools.
pip install wheel setuptools --upgrade pip3 install wheel setuptools --upgrade python -m pip install wheel setuptools --upgrade python3 -m pip install wheel setuptools --upgrade
You can also upgrade your version of pip
.
pip
Here are the commands for upgrading pip
on all operating systems.
# 👇️ 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
If you have difficulties upgrading pip, follow the instructions in this article.
If the error is not resolved, download the wheel
package from the
pypi page of wheel by clicking on the
.whl
file under "Built Distribution".
Open your terminal in the folder where the .whl
file is located and install
it.
pip install wheel-0.37.1-py2.py3-none-any.whl pip3 install wheel-0.37.1-py2.py3-none-any.whl python -m pip install wheel-0.37.1-py2.py3-none-any.whl python3 -m pip install wheel-0.37.1-py2.py3-none-any.whl
.whl
file as your version will likely be different.You can use the Tab key to autocomplete the filename if your terminal is open in the same directory as the file.
If the error is not resolved, try upgrading your version of cmake
.
pip install cmake --upgrade pip3 install cmake --upgrade # 👇️ If you don't have pip in your PATH environment variable python -m pip install cmake --upgrade python3 -m pip install cmake --upgrade
We used the --upgrade option to
get the latest version of cmake
.
If you use a requirements.txt file, try to reinstall your packages by using the following commands.
pip uninstall -r requirements.txt pip install -r requirements.txt # 👇️ Or with pip3 pip3 uninstall -r requirements.txt pip3 install -r requirements.txt
If you have multiple requirements
files, follow the instructions in
this article.
setup_requires
to your setup.py fileIf the error persists even after installing wheel
and you have a setup.py
file in the root directory of your project, add the following line to it.
setup( # rest, setup_requires=['wheel'] )
This should resolve the issue if pip install wheel
didn't get the job done.
If the error persists, try adding the following lines at the top of your
setup.py
file
import setuptools from setuptools import setup # Rest of your imports below
The setup.py
file should be in the root directory of your Python project and
is used to store metadata about the program.
If that didn't help, try creating a virtual environment.
If the error persists, try creating a virtual environment.
pip install
command with the virtual environment active.# 👇️ Use the correct version of Python when creating VENV python -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 # 👇️ install cmake pip install cmake # 👇️ upgrade pip pip install --upgrade pip # 👇️ install the specific package in the virtual environment pip install requests
If the python -m venv venv
command doesn't work, try one of the following
commands:
python3 -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 that didn't help, try installing the latest version of Python.
You can check your Python version with the python --version
command.
python --version python3 --version
You can download the latest version from the official python.org website.
Make sure to tick the following options if you get prompted:
If none of the suggestions helped and you got the error when trying to install a
package, try running the pip install
command in verbose mode.
pip install numpy -vvv pip3 install numpy -vvv python -m pip install numpy -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.