"incompatible architecture (have 'arm64', need 'x86_64')" error while installing numpy on M1 Mac with pip3 on Python Version 3.10
Asked Answered
R

5

14

I was trying to install numpy version 1.22.3 on a M1 Macbook with pip3, and pip3 says the package is present, but when I try to import the module, an error gets thrown at me that says
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.
The full text of the error is:
dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-

310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpy

thon-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-da

rwin.so' (no such file)

I followed the link to the troubleshooting documentation provided, and none of the solutions worked.
I've tried reinstalling both pip3 and Python, and that didn't work either.

Any ideas?

Ratable answered 5/4, 2022 at 3:2 Comment(4)
Sounds like the python interprerer would be x86_64 and not arm64 version, how did you install it?Bleary
@SamiKuhmonen I installed it off of the Python Website's MacOS downloads pageRatable
Got the same issue but with black package installed using pip (python 3.10). Any ideas on how to solve this issue?Abana
We had the same error on a Windows machine. We are trying to install the 64 bit version of latest python software. Will reply back how it goes.Cremate
T
6

If none of above worked for you try this way of install numpy after remove it pip uninstall numpy

arm64 installation

arch -arm64 pip install numpy

x86_64 installation

arch -x86_64 pip install numpy

or you can keep an alise for that in your bash config file:

alias pip86='arch -x86_64 pip install'
alias pip_arm='arch -arm64 pip install'
Trip answered 15/5, 2023 at 11:19 Comment(0)
A
5

I was able to fix this issue by uninstalling and reinstalling numpy in my virtual environment.

Argenteuil answered 2/5, 2022 at 17:47 Comment(2)
Did you use pip3 or pip to install numpy?Asymmetry
Same here, I created a new virtual env and installed my code dependencies, and it was fixed.Smote
R
1

I had the same issue. What worked for me was to downgrade the python version from 3.10 to 3.8 and then reinstall numpy.

Richardricharda answered 30/6, 2022 at 7:10 Comment(0)
G
0

I had this issue, what worked for me was, deleting my .venv folder in my python project directory, and remaking the poetry environment

Gymnast answered 18/1 at 18:9 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Semiweekly
S
0

To add to A. Sharif's answer, it might be necessary to purge your pip caches before reinstalling (I have run in the same problem for other libraries such as openCV or sounddevice, and this solved it). In that case, the following steps should be followed:

Uninstall Numpy

pip uninstall numpy

Purge pip caches

pip cache purge

Install numpy arm64

arch -arm64 pip install numpy

or, in most cases, a normal installation will work

pip install numpy

This should do the trick! Purging you pip caches will force pip to start from scratch when downloading numpy. The download may take more time, but it should help in installing the proper architecture.

Skeleton answered 1/8 at 14:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.