I have a python app with downstream dependencies on dynamic libraries that are available as X86 only.
The app runs on a X86 MacOS machine, but on a ARM MacOS machine it fails with an ImportError
.
I've run lipo -archs
on the libraries and they are x86_64
only. I have Python running in a virtualenv and it is a universal binary x86_64 arm64
. The intermediary object file built by the application when it installs is also a universal binary x86_64 arm64
.
I suspect that Python is being run native as an ARM app, but because of the dependencies I need it run as an X86 app.
Is there a MacOS or Rosetta2 option or environmental setting that I can use that would force the X86 Python binary to be executed as opposed to the ARM binary?
Looks like the only way to do this is to install a X86 version of python.
I found a how to guide here - https://towardsdatascience.com/how-to-use-manage-multiple-python-versions-on-an-apple-silicon-m1-mac-d69ee6ed0250
but couldn't quite get the pyenv build part to work.
So in the Rosetta i386 terminal I brew86 installed python. This put a X86 version of python into
/usr/local/bin/python3
from which I was able to create a X86 only virtualenv.Broadly the steps are from the above link (minus the pyenv parts):
/usr/local/bin/brew
/usr/local/bin/python3
)