Wednesday, June 1, 2022

[SOLVED] Manage multiple python versions on both architectures with M1 mac

Issue

Is it possible to have 2 different versions of python with different architecture on M1 macbook with tools like pyenv?

For instance, I would like to have 3.9.1 on ARM and 3.8.5 on x86 (via rosetta).

I have pyenv installed already with a new homebrew 3.0.0. Having that, I am able to install 3.9.1 for ARM (pyenv install 3.9.1). Can I now have another version which would be through rosetta?


Solution

Here is a solution that does just that. I hope it's still useful.

Quick summary:

  1. Make sure Rosetta 2 is installed (it translates software designed for x86 to something ARM can digest)
  2. Install a x86 and a ARM version of homebrew
  3. Install a x86 and a ARM version of the packages required by pyenv.
  4. Install pyenv
  5. Use aliases to refer to a x86 and an ARM version of pyenv
  6. Use pyenv-alias to install and refer to x86 and/or ARM python versions.


Answered By - Antropath
Answer Checked By - Willingham (WPSolving Volunteer)