Unfortunately, several popular data science Python packages like Pandas and Numpy don’t currently compile on the M1 or M2 chip. This post will outline an easy way to set-it-and-forget-it using Rosetta 2, which emulates Intel CISC instructions on Apple Silicon.
But what’s the advantage of doing it this way? What are the disadvantages?
Typically, you do not want to create more Python chaos than already exists, as this ecosystem can be a huge PITA to deal with.
• This method works because the code is picked up from your system & sent off to the Intel x86_64 compilation queue instead of the arm64 compilation queue.
• The disadvantage is that you’re going to end up maintaining two environments. For example, if you try to run something that’s unavailable, e.g. you installed a package with arm64 and try to run it in Intel x86_64 mode, it will fail along the lines of:
incompatible architecture (have 'arm64', need 'x86_64'))
• The good news is that as long as you stick with pipenv, homebrew, or macports then walking back the system installation is usually easy if imperfect.
• Download an alternative terminal app like iTerm2. This will set up all operations contained by the app to run in Intel x86 emulation mode, and the Python packages will compile using pipenv.
(Optional) Set up your terminal to notify you each time you open a new window by adding “echo $(uname -m)” to your .zshrc file. Kudos to indiespark for the tip about environment notification – see footnote for more info.
echo $(uname -m)
(Optional) Back in the Finder, I customized the Icon by pasting “x86” over the terminal icon in Photoshop, and on top of that, I’ve effectively created a second python environment.
Duplicating Terminal seems like a non-starter, and I would avoid doing that. Using a totally different app is safer for this use case.
- Here’s a good read about arm64 and intel modes that can outline the difference in more detail.