Setup Dual Architecture Terminal on Apple Silicon

Apple silicon is excellent until you come across some x86 binding binaries. Here is a short memo to run both arm64 and i386 terminal on macOS with Apple silicon.

Setup Specified Terminal App for i386

Apple provides a dynamic binary translator called Rosetta 2 since macOS Big Sur, to make an app "feel like" running at i386. Choose a terminal app you like and duplicate it. Here I use iTerm2 and rename the i386 one to "iTerm2 Intel". Remember to select "Open using Rosetta". After that, both terminal and its subprocess (zsh, brew, python...) will run in an i386 environment.

To check whether everything is running correctly, run arch command in terminal. It should return arm64 on the native environment and i386 on Rosetta.

Install Homebrew

Homebrew is a package manager for macOS, and it supports Intel-based Mac and Apple silicon-based Mac.

Install Homebrew on both terminals. For arm64 environment, Homebrew will install at /opt/homebrew/bin/brew, and for i386, it will install at /usr/local/bin/brew. It's no need to worry two Homebrew will conflict.

After installation, add the following script to your ~/.zprofile. It will determine the environment architecture and add the corresponding Homebrew the PATH.

if [[ $(arch) == "arm64" ]]
eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(/usr/local/bin/brew shellenv)"

Example: Install x64 Python

Run brew install python3 in the i386 terminal, and as we expected, Homebrew will download the x86 Python interpreter.

Finally, I installed PyTorch and MXNet with pip3, and my PyCharm (which runs natively on Apple Silicon) smoothly works with my x86 Python interpreter.

All rights reserved
Except where otherwise noted, content on this page is copyrighted.