21

I am gettin following error while installing python3.7 on MacBook air m1 2020. I run the following command:

brew install python@3.7

The following error is thrown:

python@3.7: The x86_64 architecture is required for this software.
Error: python@3.7: An unsatisfied requirement failed this build.

My question is that "how can I install python3.7 on MacBook Air m1 using brew??

Celik
  • 2,311
  • 2
  • 32
  • 54
  • @UlrichEckhardt Actually m1 processor is very new and there is no question/answer about it on stack overflow. So, I just want to collect the answers under this question. – Celik Dec 11 '21 at 15:10
  • https://stackoverflow.com/search?q=The+x86_64+architecture+is+required+for+this+software -- Are you sure about that? – Ulrich Eckhardt Dec 11 '21 at 15:11
  • @UlrichEckhardt yes, I am. They are not trying to install python3.7 – Celik Dec 11 '21 at 15:23
  • Has anyone got a solution to installing a proper arm version. I'm having compile time dependency issues – Shayne Dec 08 '22 at 12:17

1 Answers1

48

Based on this article, you may install Rosetta 2 to be able to use brew x86, and then use it to install python 3.7.

To install Rosetta 2:

softwareupdate --install-rosetta

Then, install brew x86 version:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Optionally, add an alias to the ~/.zshrc (or similar) file:

alias ibrew="arch -x86_64 /usr/local/bin/brew"

Now you can choose between brew when you want to install an ARM app or ibrew when you want to install x86 app.

Finally, to install x86 python 3.7 on M1:

ibrew install python@3.7
Tim
  • 12,318
  • 7
  • 50
  • 72
fn control option
  • 1,745
  • 6
  • 18
  • Installing `ibrew` failed for me at first, but running `ibrew doctor` and `git -C $(ibrew --repo homebrew/core) checkout master` after solved it. https://github.com/Homebrew/discussions/discussions/1512#discussioncomment-1746145 – Flo Dec 29 '21 at 20:32
  • But where does `ibrew` install that version of python? How do you use that version of `python`? I can't seem to find it so visibility or documentation would be helpful :) – B-Tron of the Autobots Jun 18 '22 at 12:30
  • 1
    @B-TronoftheAutobots `ibrew --prefix python@2.7` – fn control option Jun 18 '22 at 13:46
  • yes, so this shows the path as `/usr/local/opt/python@3.7/` which you can then use to run that version from - thanks! I am also curious how to alias so `python3` command uses that version but that shouldn't be too hard to find out. – B-Tron of the Autobots Jun 18 '22 at 14:00
  • 1
    @fncontroloption why did you choose to put an "i" infront of brew to differentiate it. Does this have something to do with iOS? Also, is running 3.7 in this way stable on new macs? Or would we expect some errors? – wueb Aug 08 '22 at 18:11
  • 1
    @wueb, I assume that `i` is a reference to the Intel architecture, as in "Intel x86". In practice, you may chose any name for the alias, it will work equally well. – Tim Sep 26 '22 at 18:52
  • @B-TronoftheAutobots this might be a bit late, but I'm trying to sort my python installations. running the command you suggested gives me the same output, however a symlink or a binary is not located at that path on my machine. I thought I had installed python@3.7, but its looking like not. Would running that command give me an output regardless if python@3.7 is installed or not? or is something wrong on my machine? – Jason Jan 21 '23 at 04:54