nteract / hydrogen

:atom: Run code interactively, inspect data, and plot. All the power of Jupyter kernels, inside your favorite text editor.
https://nteract.gitbooks.io/hydrogen/
MIT License
3.93k stars 333 forks source link

Cannot import numpy on macbook pro M1 #2144

Closed TillMacher closed 2 years ago

TillMacher commented 2 years ago

When trying to import numpy within Atom I get the following error message:

##################

ImportError Traceback (most recent call last) File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/init.py:23, in 22 try: ---> 23 from . import multiarray 24 except ImportError as exc:

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/multiarray.py:10, in 9 import functools ---> 10 from . import overrides 11 from . import _multiarray_umath

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/overrides.py:6, in 4 import os ----> 6 from numpy.core._multiarray_umath import ( 7 add_docstring, implement_array_function, _get_implementing_args) 8 from numpy.compat._inspect import getargspec

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-39-darwin.so' (no such file)

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last) Input In [2], in ----> 1 import numpy

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/init.py:144, in 141 # Allow distributors to run custom init code 142 from . import _distributor_init --> 144 from . import core 145 from .core import * 146 from . import compat

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/init.py:49, in 25 import sys 26 msg = """ 27 28 IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! (...) 47 """ % (sys.version_info[0], sys.version_info[1], sys.executable, 48 version, exc) ---> 49 raise ImportError(msg) 50 finally: 51 for envkey in env_added:

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:

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.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-39-darwin.so' (no such file)

##################

All other packages that do not rely on numpy can be imported. Also, importing numpy from the terminal works just fine (with python3.9), why it must rather be a hydrogen related issue. I cannot really figure out where the error originates, but suspect it is something about the M1 chip. I am using an Apple M1 Pro (macOS Monterey 12.1).

Did someone else also encounter this issue? I read various threads about problems with the new M1 chip.

TillMacher commented 2 years ago

Update: It worked when redirecting ipykernel to Python 3.7. With Python 3.8 and 3.9 the error persisted.