【发布时间】:2023-03-13 16:38:01
【问题描述】:
我刚刚安装了 Tensorflow,并试图在 Python 中运行 test program 来验证安装。当我运行程序时,通常什么都不会发生。 Spyder IDE 崩溃了几次。这是测试程序:
print('test before')
import tensorflow as tf
print('test after')
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
有趣的是,导入 tensorflow 之前的所有行都会运行,即“test before”会被打印出来。但是,该程序似乎在导入 tensorflow 时遇到了麻烦,因为没有打印“test after”。为什么程序不能成功导入tensorflow?
另外,请注意 tensorflow 安装似乎已经成功,因为最后它打印“成功安装 tensorflow-1.7.0”。并且运行程序时没有出现错误。通常,如果在导入包时出现问题,您会收到一条错误消息,例如“找不到 [包]”。在这种情况下,程序只运行几秒钟然后停止(或 IDE 崩溃)而不返回错误。运行python3 -c 'import tensorflow' 时出现错误Illegal instruction (core dumped)。
张量流版本:1.7.0 Python版本:3.5.2 使用 Spyder IDE 操作系统:ubuntu 16.04 LTS
【问题讨论】:
-
您遇到了什么错误?如果没有导入应该报错
-
从命令行试试这个:
python -c 'import tensorflow'。如果这没有打印错误,那么您的安装不是问题 -
您是否重新启动了 IDE/计算机?
-
不,我在 Spyder IDE 中没有收到任何错误。
-
我尝试运行
python3 -c 'import tensorflow',它给出了错误Illegal instruction (core dumped)
标签: python tensorflow