Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Illegal instruction: 4 when importing tensorflow in python 3.6

Writer Sebastian Wright

I installed Tensorflow on macOS with Virtualenv. Everything went okay ("Successfully installed six-1.11.0 tensorflow-1.6.0" is the last output of the terminal, once i run the command pip3 install --upgrade tensorflow). So, with the virtualenv activated, I typed: python3 and then import tensorflow as tfbut it outputs the error Illegal instruction: 4 and quits python.

I looked around to see if anybody else had encountered the same issue, but I didn't find much, apart from this question, which doesn't provide a solution. I read this answer explaining what Illegal instruction means, the point is that I'm on the latest version of macOS High Sierra:

enter image description here

Am I misunderstanding what the answer is referring to?

Do you know how I could solve this issue? Or hopefully a workaround, so that I can start using tensorflow.

Thank you in advance.

5

3 Answers

I had the same issue, so what I did was uninstalled tensorflow 1.6. installed

pip install -Iv tensorflow==1.5
pip install -Iv numpy==1.13

seems to be fine now, my guess is there was the latest bug in tensorflow 1.6.

To make sure it's compatible with the pandas, you can do: pip install -Iv numpy==1.13.3

It could not find 1.15 version for me as for @dfresh22, but that helped:

pip3 uninstall tensorflow
pip3 install -Iv tensorflow==1.5
4

Similarly, on Apple M1 with BigSur (Python 3.9), the Anaconda interface did complain about incompatible version of tensorflow for Python 3.9, pip did install from the terminal but I got "illegal instruction:4" message. Finally, the following command sorted out the necessary packages to install:

conda install conda-forge::tensorflow

the detail is here. This installation is an older version of tensorflow: tensorflow-2.7.0 .

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy