How to Install Multiple Versions of Python on Apple Silicon / M1

I struggled to build and install Python on M1. Only got this error configure: error: Unexpected output of 'arch' on OSX.

I had Homebrew and asdf installed for arm64 (default Apple Silicon / M1 architecture).

That's what worked for me: duplicate iTerm (Finder -> Applications -> Right click on iTerm -> Duplicate) and set it to run with Rosetta (Right click on the duplicated iTerm -> Get Info -> Mark "Open using Rosetta").

Rename the duplicate to something like iTerm Rosetta and you will end up with iTerm and iTerm Rosetta.

Open iTerm Rosetta and type arch, it must show i386 on iTerm Rosetta and arm64 on regular iTerm.

Install Homebrew on i386. Open iTerm Rosetta and run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)", then which brew to confirm, you must see /usr/local/bin/brew.

Homebrew for arm64 is installed on /opt/homebrew/bin/brew instead.

Now install the desired version of Python using asdf, eg: asdf install python 3.8.9.

Written on October 14, 2022

Share: