解法,檢查有無 “-arm” 即可。
在 macOS x86 取得 platform.platform()
macOS-10.15.7-x86_64-i386-64bit
在 macOS arm:
macOS-12.0.1-arm64-i386-64bit
Charles Duffy explained the problem in the comments, thank you! 😃
When I checked the platform in Python, it was indeed ARM:
> python -c 'import platform; print(platform.platform())'
macOS-12.0.1-arm64-i386-64bit
So I had been using a Python installation for ARM.
Now I installed brew
and then python3
from the Rosetta terminal and used the newly installed Python to initiate a fresh virtual environment, and this fixed it. (This article helped me a bit with it.)
Update:
When creating Python environments with conda
, it is possible to specify whether they should use Apple ARM or Intel-x64:
CONDA_SUBDIR=osx-arm64 conda create -n my_env python
makes an ARM environmentCONDA_SUBDIR=osx-64 conda create -n my_env python
makes an x64 environment