0

I'm trying to use numpy module in python 3.10 Since I use vscode, I installed numpy module in the vscode terminal at first. Then, when I tried to test some simple numpy calculation thru my local terminal, this error occurred.

<error>
>>> import numpy as np
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 <module>
    from . import multiarray
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/overrides.py", line 6, in <module>
    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')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (no such file), '/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'))
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.

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.24.2"

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')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (no such file), '/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'))

Thus, I uninstalled numpy and re-installed it through my local terminal. Then, I could import and use numpy well in my local terminal, but now I can't run python file including numpy in vscode with showing the error above in the vscode terminal.

So I always uninstall and reinstall numpy module to use it just because of difference of the platform. I want to use it in the both situation... what should I do?

soominsoo
  • 11
  • 3
  • You have multiple copies of Python, but they are compiled for different architectures. You either want to get compatible versions or check out virtual environments to separate out the libraries – Sam Mason Feb 11 '23 at 12:58
  • Oh thank you. I didn't know my m1 local terminal's default arch was i386! I will change it :) – soominsoo Feb 12 '23 at 10:50
  • I'm a Linux user so don't know how easy it is to make this this change. If it's non-trivial it might be worth posting an answer to your question to help other people, e.g.: https://stackoverflow.com/q/75425266/1358308 – Sam Mason Feb 12 '23 at 16:32

0 Answers0