Reputation: 16912
This is a truly popular question here at SO, but none of the many answers I have looked at, clearly explain what this error really mean, and why it occurs.
One source of confusion, is that when (for example) you do pip install pycparser
, you first get the error:
Failed building wheel for pycparser
which is then followed by the message that the package was:
Successfully installed pycparser-2.19
.
# pip3 install pycparser
Collecting pycparser
Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
Building wheels for collected packages: pycparser
Running setup.py bdist_wheel for pycparser ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g_v28hpp/pycparser/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-__w_f6p0 --python-tag cp36:
Traceback (most recent call last):
File "<string>", line 1, in <module>
...
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2349, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'wheel.bdist_wheel'
----------------------------------------
Failed building wheel for pycparser
Running setup.py clean for pycparser
Failed to build pycparser
Installing collected packages: pycparser
Running setup.py install for pycparser ... done
Successfully installed pycparser-2.19
What is going on here?
(I would like to understand how something can fail but still get installed and whether you can trust this package functioning correctly?)
So far the best partial explanation I have found is this.
Upvotes: 280
Views: 697487
Reputation: 295
On linux this is most likely due to build/dev tools not install. This could also affect packages like psycopg2 or pycrypto... Install this dependencies should make the issue go say.
sudo apt install build-essential libpq-dev python3-dev
Upvotes: 0
Reputation: 378
In my case, running the following solved the issue:
pip install "cython<3.0.0" wheel && pip install pyyaml==5.4.1 --no-build-isolation
Upvotes: 2
Reputation: 1367
I was getting the wheels error when installing datacompy, which uses pandas, in VS Code. This solved it for me:
pip install datacompy --no-deps --ignore-installed
Upvotes: 1
Reputation: 309
In short, it means that the package in the requirements.txt
is set to a relatively "deprecated" version, and the underlying implementation of your current Python environment cannot interpret the wheel source code, or intentionally produces errors.
One way of dealing with this is to replace "==" in the requirements.txt
with ">=". This way, you can iteratively bump versions of only the packages that require "wheel" builds.
Upvotes: -1
Reputation: 19406
(pip maintainer here!)
Update: This is no longer necessary starting Python 3.12, where pip will automatically use isolated builds in new virtual environments.
For a quick copy paste:
pip install wheel
Do that in every new virtual environment created with venv
.
Read on for the details and explaination.
If the package is not a wheel, pip tries to build a wheel for it (via setup.py bdist_wheel
). If that fails for any reason (like, missing system level libraries, incompatibilities with your system, bad version string in the built wheel, etc), you get the "Failed building wheel for {...}" message.
In some of these cases, currently, pip falls back to installing via setup.py install
, so it's possible that the installation still succeeds. That said, pip always tries to install packages via wheels as often as it can. This is because of various advantages of using wheels (like faster installs, cache-able, not executing code again etc) and the fact that it is a standardizd format; unlike the (deprecated) setup.py install interface.
Your error message here is due to the wheel
package being missing, which contains the logic required to build the wheels in setup.py bdist_wheel
. (pip install wheel
can fix that -- but it won't fix any build time issues due to system configuration)
Sometime in the future, we'll switch to a more modern build system by default (if you're a package author, you can opt-in by adding a pyproject.toml
) that will solve this issue, through isolated build environments where you will have wheel installed. :)
Upvotes: 232
Reputation: 153
for mac-os run below command in terminal
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Upvotes: -4
Reputation: 25
I've had an issue as well while installing "pyblake2" package. Working on MacOS M2! Error text (approx text): "Couldn't build wheel for pyblake2..." However "wheel" module was successfully installed!
Solution:
download package from the official source: https://pypi.org/project/pyblake2/#modal-close
run the "setup.py" by running: ~python3 setup.py
if it throws the errors:
Replace the lines:
You are welcome!
Upvotes: -1
Reputation: 161
This error mostly comes up when you do not have the required packages needed by wheel. If you are using python3, then install python3-dev or python2-dev if you are using python 2.
sudo apt-get install python3-dev
or
sudo apt-get install python2-dev
Upvotes: 6
Reputation: 1298
I stuck with this problem for several hours when I was trying to install a package that requires 'isal', but isal installation failed:
----------------------------------------
ERROR: Failed building wheel for isal
Failed to build isal
ERROR: Could not build wheels for isal which use PEP 517 and cannot be installed directly
The solution that works for me is installing libtool.
yum install libtool
Upvotes: 1
Reputation: 81
I got the same message when I tried to install
pip install django-imagekit.
So I ran
pip install wheel
(I had python 2.7) and then I reran pip install django-imagekit
and it worked.
Upvotes: 1
Reputation: 1
I was trying to install python-nmap
tool, and getting this error.
If you are on Linux platform, please make sure that the nmap
tool is installed, otherwise the library python-nmap
won't work.
On Red Hat based distribution, please install nmap
CLI as follow:
sudo yum install namp
Upvotes: -4
Reputation: 161
In my case, update the pip versión after create the venv, this update pip from 9.0.1 to 20.3.1
python3 -m venv env/python
source env/python/bin/activate
pip3 install pip --upgrade
But, the message was...
Using legacy 'setup.py install' for django-avatar, since package 'wheel' is not installed.
Then, I install wheel package after update pip
python3 -m venv env/python
source env/python/bin/activate
pip3 install --upgrade pip
pip3 install wheel
And the message was...
Building wheel for django-avatar (setup.py): started
default: Building wheel for django-avatar (setup.py): finished with status 'done'
Upvotes: 14
Reputation: 11
I had the same problem while installing Brotli
ERROR
Failed building wheel for Brotli
I solved it by downloading the .whl
file from here
and installing it using the below command
C:\Users\{user_name}\Downloads>pip install Brotli-1.0.9-cp39-cp39-win_amd64.whl
Upvotes: 0
Reputation: 173
Error :
System : aws ec2 instance (t2 small)
issue : while installing opencv python via
pip3 install opencv-python
Problem with the CMake installation, aborting build. CMake executable is cmake
----------------------------------------
Failed building wheel for opencv-python
Running setup.py clean for opencv-python
What worked for me
pip3 install --upgrade pip setuptools wheel
After this you still might received fallowing error error
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Installing libgl solved the error for me.
sudo apt update
sudo apt install libgl1-mesa-glx
Hope this helps
Upvotes: 4
Reputation: 499
I would like to add that if you only have Python3 on your system then you need to start using pip3 instead of pip.
You can install pip3 using the following command;
sudo apt install python3-pip -y
After this you can try to install the package you need with;
sudo pip3 install <package>
Upvotes: -2
Reputation: 67
This may Help you ! ....
Uninstalling pycparser:
pip uninstall pycparser
Reinstall pycparser:
pip install pycparser
I got same error while installing termcolor and I fixed it by reinstalling it .
Upvotes: -5
Reputation: 6672
On Ubuntu 18.04, I ran into this issue because the apt
package for wheel
does not include the wheel
command. I think pip tries to import the wheel
python package, and if that succeeds assumes that the wheel
command is also available. Ubuntu breaks that assumption.
The apt python3 code package is named python3-wheel
. This is installed automatically because python3-pip
recommends it.
The apt python3 wheel command package is named python-wheel-common
. Installing this too fixes the "failed building wheel" errors for me.
Upvotes: 2
Reputation: 37
Try this:
sudo apt-get install libpcap-dev libpq-dev
It has worked for me when I have installed these two.
See the link here for more information
Upvotes: 1
Reputation: 16912
Since, nobody seem to mention this apart myself. My own solution to the above problem is most often to make sure to disable the cached copy by using: pip install <package> --no-cache-dir
.
Upvotes: 64
Reputation: 3313
It might be helpful to address this question from a package deployment perspective.
There are many tutorials out there that explain how to publish a package to PyPi. Below are a couple I have used;
My experience is that most of these tutorials only have you use the .tar of the source, not a wheel. Thus, when installing packages created using these tutorials, I've received the "Failed to build wheel" error.
I later found the link on PyPi to the Python Software Foundation's docs PSF Docs. I discovered that their setup and build process is slightly different, and does indeed included building a wheel file.
After using the officially documented method, I no longer received the error when installing my packages.
So, the error might simply be a matter of how the developer packaged and deployed the project. None of us were born knowing how to use PyPi, and if they happened upon the wrong tutorial -- well, you can fill in the blanks.
I'm sure that is not the only reason for the error, but I'm willing to bet that is a major reason for it.
Upvotes: 6
Reputation: 1002
Yesterday, I got the same error: Failed building wheel for hddfancontrol
when I ran pip3 install hddfancontrol
. The result was Failed to build hddfancontrol
. The cause was error: invalid command 'bdist_wheel'
and Running setup.py bdist_wheel for hddfancontrol ... error
. The error was fixed by running the following:
pip3 install wheel
(From here.)
Alternatively, the "wheel" can be downloaded directly from here. When downloaded, it can be installed by running the following:
pip3 install "/the/file_path/to/wheel-0.32.3-py2.py3-none-any.whl"
Upvotes: 75