我正在尝试运行我使用Powershell从记事本中的文件为Tensorflow编写的程序。每当我运行python main.py
打开并执行代码时,都会出现以下错误。
我还没有找到任何尝试的方法,我唯一能做的就是卸载并重新安装Tensorflow,但这是行不通的。
C:\Users\stxrsstillfade> cd tensorflow-demo
C:\Users\stxrsstillfade\tensorflow-demo> python main.py
代码错误甚至与代码无关。追溯说问题出在第一行import tensorflow
上。
Traceback (most recent call last):
File "main.py", line 1, in <module>
import tensorflow as tf
File "C:\Python27\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
我尝试访问GitHub链接,但似乎已被删除。
谢谢您的答复。
答案 0 :(得分:0)
请按照TensorFlow website中的说明进行操作。如果您使用的是较低版本,我建议install Tensorflow 2。
要修复Failed to load the native TensorFlow runtime
,您需要从here下载并安装/更新Microsoft Visual C ++ 2015-2019可再发行组件(x64)。
如果您遇到任何其他问题,可能的原因是