M1 mac mini: Python reports `mach-o, but wrong architecture`

We've rented a M1 Mac Mini at a Cloud provider and installed python3 via homebrew.

However, when installing packages, we see many errors reporting wrong architecture mismatches.

pip3 install <something>

/private/var/folders/s9/94x83w5x5gv1tkw6pgcvy55r0000gn/T/pip-install-6zb2vf39/rchitect_2226cf31d84b4fbeb14084a47e566d22/.eggs/cffi-1.14.5-py3.9-macosx-11.4-arm64.egg/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture

Other CLI libraries work just fine with their (native) brew installations. Rosetta is not even installed.

I am not heavily into Python and searching the web did not help, hence I suspect something non-standard might be going on here.

brew info python3
[email protected]: stable 3.9.5 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/opt/homebrew/Cellar/[email protected]/3.9.5 (3,108 files, 55.5MB) *
  Poured from bottle on 2021-05-27 at 20:07:29
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: Python-2.0

which python3
/opt/homebrew/bin/python3

Does anyone have a clue what might be going on?

Edit: Here are the architectures of the files

file /opt/homebrew/bin/python3
/opt/homebrew/bin/python3: Mach-O 64-bit executable arm64

file /private/var/folders/s9/94x83w5x5gv1tkw6pgcvy55r0000gn/T/pip-install-nq_w_w15/rchitect_e1cd9cd747dc44e2a7f69885db619a02/.eggs/cffi-1.14.5-py3.9-macosx-11-arm64.egg/_cffi_backend.cpython-39-darwin.so: Mach-O 64-bit bundle x86_64

The downloaded egg of cffi is the wrong architecture. Why is this happening and who might be the bad player here?


Pypi does not provide an ARM package for this software for macOS. Only X86_64.

How do I know?

I actually went and looked.

https://pypi.org/project/cffi/#files

Edit (122621): I note that as of 101321, there appears to be an ARM build of cffi in PyPy.


I had a similar problem trying to install dask. I solved it following these steps:

1/ Check which version of python are installed (I have : mac os python 2.x and 3.x, anaconda 3.8, brew 3.9):

python -m pipenv.help

Python installations found:

  • 3.9.6: /opt/homebrew/bin/python3
  • 3.9.6: /opt/homebrew/bin/python3.9
  • 3.8.8: /opt/anaconda3/bin/python3
  • 3.8.8: /opt/anaconda3/bin/python3.8
  • 3.8.2: /usr/bin/python3
  • 2.7.16: /usr/bin/python2
  • 2.7.16: /usr/bin/python2.7

2/ Use pipenv to create a 3.8 virtual environment:

pipenv install --python '/opt/anaconda3/bin/python3'
pipenv install 'dask[complete]'

Note: by default, pipenv was using the 3.9 brew version of python to create the virtual environment - which caused the problem.

3/ Activate the virtual environment and use it:

pipenv shell