41

I am trying to install a package which uses PEP 517. The newest version of Pip won't allow me to install due to an error involving wheel building for 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 No module named 'pip._internal.cli.main' error.

How can I solve this?

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
Sean Payne
  • 1,625
  • 1
  • 8
  • 20
  • 1
    Have you tried the solution posted [here](https://github.com/conda/conda/issues/9912)? `python -m pip install --upgrade pip --user` – Alexander Freyr Sep 24 '20 at 02:55
  • 2
    Yes, that didn't work for me. I've solved the issue and will answer my own question below. – Sean Payne Sep 24 '20 at 03:48
  • I had similar issues installing pytype on windows. The solution was to use an older version of the lib. see [github issue](https://github.com/google/pytype/issues/727) – mihca Jul 06 '21 at 17:28
  • There are **system dependencies** for the package https://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) – L3Loup Aug 18 '21 at 03:31

9 Answers9

26

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.

Sean Payne
  • 1,625
  • 1
  • 8
  • 20
  • 1
    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 https://pypi.org/simple -- 'cffi>=1.0.0' Check the logs for full command output. i got this error now – Sandrin Joy Jan 10 '21 at 06:55
  • 23
    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. – Janos May 30 '21 at 12:38
  • 2
    I am the OP and it worked, which is why I self answered my own question – Sean Payne Jun 03 '21 at 00:17
  • 1
    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. – vesperto Feb 21 '22 at 15:22
23

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

Mleen
  • 271
  • 1
  • 6
  • 4
    Please [don’t post images of code, error messages, or other textual data.](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557) - especially, tiny, extremely low-contrast images. – tripleee Oct 24 '22 at 16:42
12

This solution from this link helped me:

pip install --upgrade pip setuptools wheel
Joel Oduro-Afriyie
  • 1,563
  • 14
  • 13
6

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!

KevinG
  • 109
  • 2
  • 5
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.

Alexander Santos
  • 1,458
  • 11
  • 22
5

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.

o0lemon_pie0o
  • 51
  • 1
  • 1
1

try this: pip3 install --upgrade pip

Leonardo
  • 120
  • 9
0

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

export SYSTEM_VERSION_COMPAT=1
-5

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.

person_v1.32
  • 2,641
  • 1
  • 14
  • 27
yubari
  • 1