使用pip install tensorflow命令后,在cmd下进入python环境后运行如下代码:
1 2 3 4 | import tensorflow as tf h = tf.constant('Hello Tensorflow!') s = tf.Session() print(s.run(h)) |
发现出现错误提示:ImportError: DLL load failed,如下图所示:
解决办法:打开Anaconda Prompt,输入以下命令:
1 | pip install tensorflow==1.15 |
注意:不能使用tensorflow的过高版本,我的python是3.7,使用的是tensorflow 1.15就可以。
最后能够成功输出hello tensorflow语句,即tensorflow导入成功