Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

numpy build fail in M1 Big sur 11.1

I am using MacBook m1 which is running Big Sur 11.1 ,and I have installed Xcode-commandline-tools version 12.3 and it has installed python3.8.5 and pip3 .python3 and pip are native apps,that is they run in ARM

pip3 version 20.3.3

python3 version 3.8.5

setuptools version 51.0.0

wheel version 0.36.2

when I type python3 -m pip install numpy

The output is :

Defaulting to user installation because normal site-packages is not writeable
Collecting numpy
  Using cached numpy-1.19.4.zip (7.3 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Building wheels for collected packages: numpy
  Building wheel for numpy (PEP 517): started
sandeep@Sandeeps-Air ~ % cat a
Defaulting to user installation because normal site-packages is not writeable
Collecting numpy
  Using cached numpy-1.19.4.zip (7.3 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Building wheels for collected packages: numpy
  Building wheel for numpy (PEP 517): started
  Building wheel for numpy (PEP 517): finished with status 'error'
Failed to build numpy

and with a very large list of errors

Is numpy still not supported in M1 or am I doing it wrong ?

like image 297
zsh Avatar asked Dec 17 '20 08:12

zsh


People also ask

Could not build wheels for NumPy which use PEP 517 and Cannot be installed directly m1?

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 is the latest version of NumPy?

NumPy 1.21. 0 (release notes) – 22 Jun 2021. NumPy 1.20. 3 (release notes) – 10 May 2021.

Does NumPy work with OpenBLAS on M1?

I did a quick test building OpenBLAS on the M1 (works fine), but numpy still doesn't work when linked against that library. It produces roughly the same errors as @picn0113 's build above (which also includes OpenBLAS).

Why importing the NumPy C-extensions failed?

Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.

Is it possible to install NumPy in Apple Silicon?

I have tested Python3.9 install Numpy using -m venv in x86_64 in Apple Silicon successfully. Make sure you are using x86_64 python3.9 not the native.

How to install NumPy without TensorFlow?

So, if you don't want to use tensorflow and want to use numpy by using pip install then go ahead install python3.9 and make it your default python interpreter. I will recommend you to use Homebrew for installation of python 3.9 as it as easy as running a simple command. could you add links to documentation that support what you are saying, please?


Video Answer


3 Answers

I had exactly the same issue with my brand new Mac Mini. After spending an afternoon reading this issue on github, I finally succeeded. However, it only seems to work with v1.20.0rc2 or above...

Long story short, these were the steps I've taken to get it working:

pip3 install Cython
git clone https://github.com/numpy/numpy.git 
cd numpy
pip3 install . --no-binary :all: --no-use-pep517

After that, I could cd into my virtualenv and import numpy:

>>> import numpy as np
>>> np.__version__
'1.21.0.dev0+402.gc4ae3ce64'
>>> 

Next up: pandas.

UPDATE: After some more searching, I found this interesting article, which states that you can easily start Terminal in Rosatta mode. That also solved the issues.

However, I am working with a headless Mac Mini, so I still have to find out whether that solution also is feasable in that particular setup.

UPDATE 2

I now have pandas working as well, thanks to this answer on SO.

like image 138
Bart Barnard Avatar answered Oct 18 '22 22:10

Bart Barnard


Yes, numpy still seems to be not supported in stable, but if you are ready to work with unstable version try this command:

pip3 install numpy --compile --pre

This will recompile all the necessary code from unstable branch.

Worked for me.

like image 21
Mikhail Karavashkin Avatar answered Oct 18 '22 20:10

Mikhail Karavashkin


Since NumPy 1.21.0, it has released universal2 wheels for Python 3.8 and Python 3.9 on Mac. It becomes installable on Mac M1.

I have tested it on my M1 with Python 3.9.2, macOS Big Sur (11.5.1), and pip 21.1.3. Just use pip/pip3 to install it.

release note: https://github.com/numpy/numpy/releases/tag/v1.21.0

like image 8
Grimmer Kang Avatar answered Oct 18 '22 22:10

Grimmer Kang