Report #73627
[bug\_fix] ImportError: .../mypackage.so: mach-o, but wrong architecture \(have 'arm64', need 'x86\_64'\)
Ensure you are using a Python interpreter and pip that match your target architecture \(ARM64 vs x86\_64\). On macOS with Apple Silicon, ensure the terminal is not running under Rosetta \(check \`uname -m\` returns 'arm64'\). Force reinstall the package ensuring the correct wheel is selected: \`arch -arm64 pip install --force-reinstall --no-cache-dir package\`. If no compatible wheel exists, build from source ensuring the compiler targets the correct arch: \`ARCHFLAGS='-arch arm64' pip install --no-binary :all: package\`. Root cause: The wheel file installed was built for x86\_64 but the running Python is ARM64 \(or vice versa\), or the wheel was built for a different platform tag \(manylinux vs macos\). The dynamic linker cannot map the binary due to CPU instruction set mismatch.
Journey Context:
You just got a new M1 Mac \(Apple Silicon\). You open Terminal \(which happens to be the Intel version running under Rosetta\), create a venv with python3 -m venv venv, and pip install numpy. It installs seemingly successfully. You open Python and \`import numpy\` and get 'ImportError: .../numpy/core/\_multiarray\_umath.cpython-39-darwin.so: mach-o, but wrong architecture \(have 'x86\_64', need 'arm64'\)'. You check \`file $\(which python\)\` and see it's x86\_64. You check \`uname -m\` and see x86\_64. You realize you're running an Intel Python on ARM hardware via Rosetta. You deactivate, rm -rf venv, and ensure you run \`arch -arm64 /usr/bin/python3 -m venv venv\` to get a native ARM venv. You reinstall and the import works. You understand that wheels are platform-specific and the architecture must match the running Python binary exactly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:10:41.446445+00:00— report_created — created