13

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'))

matthew cuevas
  • 131
  • 1
  • 1
  • 3
  • 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 Mac](https://apple.stackexchange.com/questions/409746/run-everything-in-rosetta-2-on-silicon-mac) – paulyang0125 May 19 '22 at 18:26
  • 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. – paulyang0125 May 19 '22 at 18:38
  • same question for almost all the python package, why Apple did not test anything? – DunkOnly Dec 09 '22 at 09:33

5 Answers5

8

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

Touwer
  • 301
  • 2
  • 5
4

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
Jakob
  • 663
  • 7
  • 25
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.

artyom.razinov
  • 610
  • 3
  • 17
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:

no-stale-reads
  • 177
  • 1
  • 1
  • 11
-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.

Sergio Bernal
  • 2,126
  • 9
  • 20