简体   繁体   English

非法指令:在 python 3.6 中导入 tensorflow 时为 4

[英]Illegal instruction: 4 when importing tensorflow in python 3.6

I installed Tensorflow on macOS with Virtualenv.我使用Virtualenv 在 macOS上安装了 Tensorflow。 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 ).一切顺利(“成功安装 6-1.11.0 tensorflow-1.6.0”是终端的最后输出,一旦我运行命令pip3 install --upgrade tensorflow )。 So, with the virtualenv activated, I typed: python3 and then import tensorflow as tf but it outputs the error Illegal instruction: 4 and quits python.因此,在激活 virtualenv 的情况下,我输入: python3 ,然后import tensorflow as tf ,但它输出错误Illegal instruction: 4并退出 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:我读了这个解释非法指令意味着什么的答案,重点是我使用的是最新版本的 macOS High Sierra:

在此处输入图像描述

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.或者希望有一个解决方法,以便我可以开始使用 tensorflow。

Thank you in advance.先感谢您。

I had the same issue, so what I did was uninstalled tensorflow 1.6.我有同样的问题,所以我所做的是卸载 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.现在似乎很好,我猜是 tensorflow 1.6 中有最新的错误。

To make sure it's compatible with the pandas, you can do: pip install -Iv numpy==1.13.3为了确保它与熊猫兼容,你可以这样做:pip install -Iv numpy==1.13.3

It could not find 1.15 version for me as for @dfresh22, but that helped:对于@dfresh22,它无法为我找到 1.15 版本,但这有帮助:

pip3 uninstall tensorflow
pip3 install -Iv tensorflow==1.5

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.同样,在带有 BigSur(Python 3.9)的 Apple M1 上,Anaconda 界面确实抱怨 Python 3.9 的 tensorflow 版本不兼容,pip 确实从终端安装但我收到“非法指令:4”消息。 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.本次安装的是旧版本的tensorflow:tensorflow-2.7.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM