close

[Solved] “zsh: illegal hardware instruction python” when installing Tensorflow on macbook pro M1

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error “zsh: illegal hardware instruction python” when installing Tensorflow on macbook pro M1 in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How “zsh: illegal hardware instruction python” when installing Tensorflow on macbook pro M1 Error Occurs?

Today I get the following error “zsh: illegal hardware instruction python” when installing Tensorflow on macbook pro M1 in Python.

How To Solve “zsh: illegal hardware instruction python” when installing Tensorflow on macbook pro M1 Error ?

  1. How To Solve “zsh: illegal hardware instruction python” when installing Tensorflow on macbook pro M1 Error ?

    To Solve “zsh: illegal hardware instruction python” when installing Tensorflow on macbook pro M1 Error I've found the answer. Seemed like my terminal app was running in Rosetta. This can be changed by right clicking on the app -> get info -> disable “open with rosetta”.

Solution 1


Python3 is shipped with 2 architectures in M1.

$ file $(which python3)
# If you installed python through Homebrew or Anaconda, deactivate your conda env, then run this line instead:
# $ file $(which /usr/bin/python3)
/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python3 (for architecture arm64e): Mach-O 64-bit executable arm64e

Here, it’s very important to specify which one to use. You can do this by installing the script like this:

arch -arm64 bash install_venv.sh my_tf_env

if you have multiple python installations, use:

arch -arm64 bash install_venv.sh --python=/usr/bin/python3 my_tf_env

You can replace my_tf_env with any other name/path you choose.

Solution 2

I’ve found the answer. Seemed like my terminal app was running in Rosetta. This can be changed by right clicking on the app -> get info -> disable “open with rosetta”.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment