What is the meaning of “Failed building wheel for X” in pip install?

后端 未结 12 1022
执念已碎
执念已碎 2020-12-07 13:54

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 sour

相关标签:
12条回答
  • 2020-12-07 14:08

    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.

    0 讨论(0)
  • 2020-12-07 14:17

    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

    0 讨论(0)
  • 2020-12-07 14:17

    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. Thanks

    0 讨论(0)
  • 2020-12-07 14:18

    (pip maintainer here!)

    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, you get the "Failed building wheel for pycparser" message and pip falls back to installing directly (via setup.py install).

    Once we have a wheel, pip can install the wheel by unpacking it correctly. pip 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).


    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.)


    The above is the legacy behavior that is currently the default; we'll switch to PEP 517 by default, sometime in the future, moving us to a standards-based process for this. We also have isolated builds for that so, you'd have wheel installed in those environments by default. :)

    • PEP 517: A build-system independent format for source trees
    • A blog post on "PEP 517 and 518 in Plain English"
    0 讨论(0)
  • 2020-12-07 14:19

    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"
    
    0 讨论(0)
  • 2020-12-07 14:19

    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;

    medium
    real python

    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.

    0 讨论(0)
提交回复
热议问题