(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
Asked Answered
O

7

17

Followed this guide (Cannot pip install mediapipe on Macos M1) to install Mediapipe on M1 mac, and now I am unable to use pandas or numpy.

ImportError: dlopen(/Users/matthewcuevas/Library/Python/3.8/lib/python/site-packages/pandas/_libs/interval.cpython-38-darwin.so, 0x0002): tried: '/Users/matthewcuevas/Library/Python/3.8/lib/python/site-packages/pandas/_libs/interval.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

Omaromara answered 19/5, 2022 at 17:20 Comment(3)
One way: arch -x86_64 pip install pandas numpy. This will run pip command under x86_emulation but the terminal stays in the native arm environment. Another way: Open Terminal App using Rosetta 2 which emulates a x86 environment, see Run everything in Rosetta 2 on Silicon MacTuition
btw, I don't need to arch to x86_64 to install mediapipe in my M1 Mac so just remove your x86_64 python and reinstall the one for arm64 and then upgrade your pip again by python -m pip install --upgrade pip and then install mediapipe whose arm64 version should be available now.Tuition
same question for almost all the python package, why Apple did not test anything?Trifacial
M
10

I got an error like this too. Solved it after a lot of trial & error.

The Problem: my brew was still running on Rosetta. Fixed that by uninstalling, cleaning and reinstalling. So everything seemed to run fine. Except this problem still kept cropping up

Until I discovered that pip is quite agressive in caching. So it caches the build even if the architecture changed. Solution: pip cache purge. Or remove the whole cache directory which you find with pip cache info

Measure answered 22/9, 2022 at 11:43 Comment(1)
pip cache purge worked for me, even though encountered with a totally different packageToothbrush
H
10

pandas and numpy seem to have been installed using the wrong architecture. You can fix that by uninstalling current versions and installing them with the architecture your machine runs on (M1, or arm64, in this case).

python -m pip uninstall pandas numpy

Now, install their arm64 equivalents. To make sure you're not using the cashed versions (x86_64) that were used before, you can add the --no-cache flag to download the arm64 versions.

arch -arm64 python -m pip install numpy pandas --no-cache
Harwell answered 17/3, 2023 at 12:3 Comment(0)
I
1

This will not be answer to your question/specific situation (most probably), but I got this issue when using python built for pyenv/virtualenv, and rm -rf ~/.pyenv helped me. So, python was reinstalled (properly this time; reinstalled by other scripts in our CI, because I deleted installation), and it's built for x86 and works fine on arm.

Invalidate answered 22/8, 2022 at 17:53 Comment(0)
L
0

I solved by installing with conda instead of pip.

So, instead of
pip install pydantic==yourversion
Use:
conda install pydantic==yourversion.

Or, you can try installing with --no-binary (it saved me in a similar issue):
pip install pydantic==version --no-binary :all:

Loam answered 13/10, 2022 at 13:21 Comment(0)
F
0

As someone who stumbled across this a year later looking for help, let me tell you how broken the Python ecosystem is on macOS, all because no one has bothered to implement platform auto-detection.

The canonical way I found is to first install the ARM64 version of Miniconda. You can use that to create your Python environments.

That's not enough though; once you have it installed, you need to explicitly tell it to use the arm64 subdirectory for all packages. Because nothing in Python is smart enough to detect your platform. So to do that:

conda config --env --set subdir osx-arm64

Now any packages you install will use the native version. Godspeed.

Fructose answered 8/2 at 17:58 Comment(0)
V
0

conda install pyworld fixed it for me.

conda install conda-forge::pyworld

Vaisya answered 17/5 at 21:43 Comment(0)
C
-2

Go to Applications -> Xcode, then right click and select get info. Then enable checbox "Open using Rosetta"enter image description here

Finally close Xcode and open it and try again.

Canon answered 24/5, 2022 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.