Fixing Tensorflow error – zsh illegal hardware instruction python

Tensorflow error – zsh: illegal hardware instruction python is an error which usually occurs because of a faulty TensorFlow installation.

In this blog post I will get into what occurs when you get this error and how we can get rid of it with a main solution, I will also try to present other solutions if possible.

Explaining the Tensorflow error – zsh illegal hardware instruction python

This is an error which usually occurs because of a faulty TensorFlow installation.

Your error message should match the one bellow. We want to avoid confusion by not mixing between error messages.

Fixing Tensorflow error - zsh illegal hardware instruction python-problem-banner

To solve the problem above, I have one solution which have worked for me, bellow is a detailed explanation of that solution.

Solution : Corretly install TensorFlow on a new python virtual environment

First of all you should start by installing the latest version of python by using pyenv .

Once you have that covered, you can check if you have installed the correct python version by using the simple command bellow.

                                                                       #
# check if you installed the correct python version with this command
python -V
                                                                       #

The next step is to install virtualenv using pip

                                                                       #
# install virtualenv using pip
pip install virtualenv
                                                                       #

Create and activate an virtual environment using the commands bellow.

Fixing Tensorflow error - zsh illegal hardware instruction python-problem-banner-1

Head into this Tensorflow official download Link. And install the wheel .whl corresponding to the latest version of Tensorflow if possible.

Run the command bellow in your virtual environment

Fixing Tensorflow error - zsh illegal hardware instruction python-problem-banner-2

The solution should be gone by now, I wish you good luck.

I hope this solution helped you solve the issue

Summing-up

The solutions solved the error Tensorflow error – zsh: illegal hardware instruction python for me and most other developers who had a similar issue, I hope you found a solution in our article, keep creating and keep coding, cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/