Roshan
Roshan

Reputation: 513

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.

Upvotes: 32

Views: 115912

Answers (5)

dgor
dgor

Reputation: 862

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

Upvotes: 25

Kashish Khurana
Kashish Khurana

Reputation: 329

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.

Upvotes: 32

vpap
vpap

Reputation: 1557

Similarly to the answers above, switching to Python 3.8 solved the issue. Additionally, because of this issue, I couldn't install scikit-image which depends on numpy.

I created a virtual environment of Python 3.8 using conda i.e. conda create -n py38 python=3.8 to switch python version. I have Mac M1, 2020 updated to OS Monterey, version 12.0.1.

Upvotes: 3

akshay shekkari
akshay shekkari

Reputation: 19

yea, I was also using python 3.10 and switched back to python 3.8.

check this link python/downloads to download python 3.8

Upvotes: 1

some random nerd
some random nerd

Reputation: 102

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.

Upvotes: 3

Related Questions