0

I am using an Apple Macbook Air with M1 silicon, MacOs 12.2.1, and the Python 3.10 version. Currently using Python for ATOM text editor with Script package extension.

My target is to use Numpy so I installed it on my system using:

pip3 install NumPy 

the installation successfully added the package to the following folders:

  • /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy
  • /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy-1.22.4.dist-info

When I try to import NumPy I get the following error:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/init.py", line 23, in from . import multiarray File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in from . import overrides File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/overrides.py", line 6, in from numpy.core._multiarray_umath import ( ImportError: 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.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-darwin.so' (no such file)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/username/Desktop/Script.py", line 10, in import numpy File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/init.py", line 144, in from . import core File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/init.py", line 49, in raise ImportError(msg) ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

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.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.10 from "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3" * The NumPy version is: "1.22.4"

and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.

Original error was: 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.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-darwin.so' (no such file)

[Finished in 0.114s]

so I understand that the problem is that I need the x86_64 version of the package. How can I force the pip3 installation using the x86_64 version?

I searched here on SO, but the only question I found was this, the provided solution (uninstall and reinstall) does not work for me.

Nicolaesse
  • 2,554
  • 12
  • 46
  • 71
  • 1
    Did you read the “common reasons and troubleshooting tips”? – Ryan Zhang Jun 06 '22 at 09:57
  • Yes, as described I am not using Anaconda, PyCharm, VSCode, Eclipse or Raspberry, or Windows. No info at all about MacOS on that page. – Nicolaesse Jun 06 '22 at 10:01
  • Have you searched around for "install numpy on m1"? – 9769953 Jun 06 '22 at 10:02
  • The fact that it is installed in `/Library/...`, i.e., the Library root folder, does that mean you ran it as admin/with sudo, not as a user? – 9769953 Jun 06 '22 at 10:04
  • solution in link uses virtual environment and maybe it makes difference. But wikipendia for [Apple M1](https://en.wikipedia.org/wiki/Apple_M1) shows that it uses architecture `ARM`. And I think it is not `x86_64`. Probably Apple used ARM but with some modifications and now it would need special version of numpy compiled for this version. – furas Jun 06 '22 at 11:03
  • Numpy works well on ARM platforms with no problem. I just did that few days ago with pip (on Linux). I do not think you need a x86 version since it would use Rosetta that introduce some overhead and issues (not to mention that AFAIK x86-64 libraries need x86-64 dependencies recursively so you may end up installing a lot of thing and few may not work in the end). – Jérôme Richard Jun 06 '22 at 11:22

0 Answers0