0

Running code that worked well on my 2019 Mac book air, I face issues with my new M2 Mac book pro. The problem is related to Numpy and Pandas. How can I get them to work on M2.

The error code is

Traceback (most recent call last): File "/Users/wolfgangseidel/Documents/HF_Project/Hike_Radar.py", line 3, in import pandas as pd File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/init.py", line 16, in raise ImportError( ImportError: Unable to import required dependencies: numpy:

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.9 from "/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9"
  • The NumPy version is: "1.20.1"

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: '/Applications/Python 3.9/IDLE.app/Contents/Frameworks/_multiarray_umath.cpython-39-darwin.so' (no such file), '/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 (x86_64), need (arm64e)))

7
  • Read this part of the error: "mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))", you somehow installed a x86_64 library while an ARM library is needed for your python interpreter. This is the problem. How exactly did you install numpy and pandas? Commented Aug 25, 2022 at 7:31
  • 1
    I recommend using the Anaconda Distribution, it's likely to make your life much easier. All packages are installed as precompiled binaries. Package List. If you are using Anaconda, do not use pip to install packages that exist within the conda ecosystem. Use conda install package. Only use pip if the package is not available with conda install. Using pip can potentially wreck your installation because pip and conda do not manage dependencies in the same way. Commented Aug 25, 2022 at 16:38
  • 1
    Thank you so much Dr. Snoopy and Trenton McKinney. How did I install? I migrated all data/files from my old 2019 Macbook to my new 2022 M2 Macbook. This way, I possibly got x86_64 versions onto my M2 machine. Thus, first step is to uninstall all packages (with "pip freeze" I found >20). "pip uninstall numpy" gives: Commented Aug 27, 2022 at 14:52
  • And: Found existing installation: numpy 1.20.1 Uninstalling numpy-1.20.1: Would remove: /Library/Frameworks/Python.framework/Versions/3.9/bin/f2py /Library/Frameworks/Python.framework/Versions/3.9/bin/f2py3 /Library/Frameworks/Python.framework/Versions/3.9/bin/f2py3.9 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy-1.20.1.dist-info/* /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/* Proceed (Y/n)? Y ERROR: Exception: Traceback (most recent call last): Commented Aug 27, 2022 at 14:53
  • File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 806, in move os.rename(src, real_dst) PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.9/bin/f2py' -> '/private/var/folders/72/njx4kk8d6p71frytz9_q37hc0000gn/T/pip-uninstall-z7vr08ay/f2py' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/wolfgangseidel/Library/Python/3.9/lib/python/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper Commented Aug 27, 2022 at 14:54

1 Answer 1

-3

I would not recommend using the MacOS built in Python framework. Try to install the Python environment using homebrew.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.