Could not build wheels for _ which use PEP 517 and cannot be installed directly
Asked Answered
B

12

60

I am trying to install a package which uses PEP 517. The newest version of Pip won't allow me to install it due to an error involving building wheels for PEP 517.

In the past, I've solved this issue by downgrading Pip, installing the package and upgrading Pip back to the latest version. However, after I downgrade pip in my virtualenv, if I try to run pip install black I get the error

No module named 'pip._internal.cli.main'

How can I solve this?

Baghdad answered 24/9, 2020 at 2:22 Comment(4)
Have you tried the solution posted here? python -m pip install --upgrade pip --userCopenhagen
Yes, that didn't work for me. I've solved the issue and will answer my own question below.Baghdad
I had similar issues installing pytype on windows. The solution was to use an older version of the lib. see github issueYellowwood
There are system dependencies for the package pypi.org/project/pypotrace (scroll down). As o0lemon_pie0o answered, check what libraries/packages you are missing with the verbose flag. (I'm using OSX and missing libagg library)Hanzelin
B
27

The easiest solution to deal with the error

"Could not build wheels for ____ which use PEP 517 and cannot be installed directly" 

is the following:

sudo pip3 install _____ --no-binary :all:

Where ____ is obviously the name of the library you want to install.

Baghdad answered 24/9, 2020 at 3:50 Comment(4)
RROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-ereh_rp4/normal --no-warn-script-location -v --no-binary :all: --only-binary :none: -i pypi.org/simple -- 'cffi>=1.0.0' Check the logs for full command output. i got this error nowYovonnda
Does not work for me. A comment would help why you think this suggestion would help. Also installing pip using sudo isn't a good idea. The OP obviously uses a virtual environment.Selfpropulsion
I am the OP and it worked, which is why I self answered my own questionBaghdad
Your self-answer didn't work for me, i got the same error as @SandrinJoy while running in msys shell in a windows 7 vm.Iberian
S
26

This error came up for the h5py library during the installation of Tensorflow. I checked the h5py documentation to make sure I had the right versions of pip and setuptools, https://pip.pypa.io/en/stable/reference/pip/.

pip install --upgrade pip setuptools wheel

I then checked the error log to identify what has caused h5py to fail while installing backend dependencies. I identified it was the libhdf5.so, where it says "error: libhdf5.so cannot open shared object file: No such file or directory". I installed the library by running:

sudo apt-get install libhdf5-dev

After this, the h5py installed successfully alongside TensorFlow. I've come across similar PEP 517 errors caused by missing dependencies:

  1. ERROR: Could not build wheels for glpk which use PEP 517 and cannot be installed directly
  2. ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly

PEP 517 error

Streamway answered 17/11, 2020 at 14:0 Comment(1)
Please don’t post images of code, error messages, or other textual data. - especially, tiny, extremely low-contrast images.Gorky
M
15

This solution from this link helped me:

pip install --upgrade pip setuptools wheel
Medora answered 27/6, 2022 at 22:47 Comment(0)
D
8

Sometimes this can be due to a cache issue and the no-binary flag won't work. In which case try pip install <insert package names> --no-cache-dir.

This seems to be a frequent issue when installing packages with python. First, check to ensure you have activated the virtualenv you think you're supposed to be in, then check to see if you have wheels pkg (pip install wheel if not). If those fail then the --no-cache-dir or --no-binary flags come into play. Reading the pypi documentation on each package could help as well. Best of luck!

Deenadeenya answered 7/5, 2021 at 20:27 Comment(0)
M
6

When I ran into this error, the problem was that the package I was pulling had its metadata configured incorrectly, which caused building the wheels to fail.

To find that error I ran, pip --verbose install <my_package> Which let me see what about the wheel build was failing, and fix it upstream.

Mclain answered 22/7, 2021 at 6:5 Comment(0)
U
5

Posting an answer as reference for future searchers here.

I tried installing Pillow and got this error. Tried many different approaches, none of them worked. Then i downgraded Python (From 3.9) to 3.8 and just tried installing by pip again, then it worked.

If it fails for you, try downgrading Python, and it may work.

Uzziel answered 9/12, 2020 at 14:46 Comment(2)
Tried with python 2.7, 3.0,. 3.6 .. no success at allDiathesis
Downgrading to 3.8(.10) also worked for me.Zworykin
Z
2

Check if you have python dev part installed. If not then:

sudo apt update
sudo apt install python3.X-dev
Zavras answered 8/11, 2023 at 13:48 Comment(0)
N
2

You can try this -->

pip install --use-pep517 'package_name'

Nadinenadir answered 23/4 at 10:4 Comment(0)
C
1

try this: pip3 install --upgrade pip

Coralloid answered 17/3, 2023 at 17:19 Comment(0)
E
0

On OSX setting SYSTEM_VERSION_COMPAT=1 in my environment prior to running pip solved it:

export SYSTEM_VERSION_COMPAT=1
Enharmonic answered 26/4, 2022 at 11:17 Comment(0)
N
0

No posted solutions worked for me (trying to install packages via poetry in my case).

Fixed it for myself, and it turns out it was a rouge conda installation - I discovered (when looking at the failed builds) that it was using *.h files from my miniconda installation, which was weird to me, since I would have expected that to be isolated from poetry (which I installed via pipx).

Solution in my case was to wipe out conda entirely (I don't really need it), and then poetry install ... worked like a charm.

Nannettenanni answered 4/4 at 2:14 Comment(0)
S
-7

I have also encountered the same issue when uninstalling and reinstalling miniconda.

I have no idea why, but in my registry key Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor AutoRun has been set to if exist. I deleted the value then it worked fine just as before.

Senility answered 9/9, 2021 at 2:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.