Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an error saying "Could not build wheels for numpy which use PEP 517 and cannot be installed directly" while installing numpy

I am trying to install a specific version of numpy using the command pip install numpy=1.19.1 in a python virtual environment. But I am getting the following errors

ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly

How do I solve this? I am using Python 3.9.6 and Pip 21.1.3. And I am on macOS Big Sur.

like image 944
Roshan Avatar asked Jul 13 '21 05:07

Roshan


People also ask

How do you fix could not build wheels for NumPy which use PEP 517 and Cannot be installed directly?

To Solve ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly Error Just update your pip and your error will be solve. pip3 install –upgrade pip. this error solved just after update pip with setuptools wheel just run below command. pip install –upgrade pip setuptools wheel.

What version of NumPy does Python 3.7 use?

According to the metadata shown on PyPI, the last released version of NumPy to support Python 3.7 is 1.21 (e.g. pypi.org/project/numpy/1.21.6).


3 Answers

I was facing the same error on my MacBook Air(macOS BigSur) Laptop while installing the Numpy package via integrated terminal of VS Code. And I found the solution: So previously I was using older version of pip i.e. 19.2.3. But when I upgraded it to the latest version using command

pip install --upgrade pip

and after that when running the command

pip install numpy 

it worked absolutely fine.

At the time running the above commands, my python version was 3.8.2.

like image 94
Kashish Khurana Avatar answered Oct 21 '22 04:10

Kashish Khurana


I think NumPy is not yet being prepared for Python 3.9 since they need to check a lot of times. You should try Python 3.7 or 3.8 is better.

See this thread: https://github.com/numpy/numpy/issues/17569

Edit: Based on the latest news on numpy's website (dated 31st December) Numpy appears to now be supporting python 3.9 and 3.10 as well

like image 18
dhgoratela Avatar answered Oct 21 '22 06:10

dhgoratela


If you're on Windows, then install Visual Studio 2019 Build Tools, then go to 'Individual components', then tick the latest version of 'Windows 10 SDK', and 'MSVC v142 x64/86 build tools - Latest'. That solved this error for me, except for me this error came when installing discord.py.

Try seeing if it works with Python 3.8 first though, just like Dhananjay's answer. That could save you a lot of storage, because Visual Studio takes up lots of space. If that doesn't work, you can try my answer.

Edit: I just realised, you said you're on Mac. Try this:

  • type python -VV in terminal
  • It should say something like this:
Python 3.9.6 (default, Jun 29 2021, 10:19:25)
[GCC 10.3.0]

Whatever it says on the second line is what you will need to install. I use Python on Ubuntu 21.10 on WSL2, which uses GCC 10.3.0, and I have GCC 10.3.0 installed.

like image 3
some random nerd Avatar answered Oct 21 '22 06:10

some random nerd