关于python 3.x:在windows中导入tensorflow模块时出现问题

having issue importing tensorflow module in windows

import tensorflow
Traceback (most recent call last):
File"D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
File"D:\python36\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'


在处理上述异常期间,发生了另一个异常:

Traceback(最近一次调用最后一次):
文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow.py",第58行,in
来自tensorflow.python.pywrap_tensorflow_internal import *
文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow_internal.py",第28行,in
_pywrap_tensorflow_internal = swig_import_helper()
swig_import_helper中的文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow_internal.py",第20行
import _pywrap_tensorflow_internal
ModuleNotFoundError:没有名为'_pywrap_tensorflow_internal'的模块

在处理上述异常期间,发生了另一个异常:

Traceback(最近一次调用最后一次):
文件",第1行,in
文件"D: python36 lib site-packages tensorflow__init __。py",第24行,in
来自tensorflow.python import pywrap_tensorflow #pylint:disable = unused-import
文件"D: python36 lib site-packages tensorflow python__init __。py",第49行,in
来自tensorflow.python导入pywrap_tensorflow
文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow.py",第74行,
引发ImportError(msg)
ImportError:Traceback(最近一次调用最后一次):
swig_import_helper中的文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow_internal.py",第18行
fp,pathname,description = imp.find_module('_ pywrap_tensorflow_internal',[dirname(file)])
在find_module中输入文件"D: python36 lib imp.py",第296行
引发ImportError(_ERR_MSG.format(name),name = name)
ImportError:没有名为'_pywrap_tensorflow_internal'的模块

在处理上述异常期间,发生了另一个异常:

Traceback(最近一次调用最后一次):
文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow.py",第58行,in
来自tensorflow.python.pywrap_tensorflow_internal import *
文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow_internal.py",第28行,in
_pywrap_tensorflow_internal = swig_import_helper()
swig_import_helper中的文件"D: python36 lib site-packages tensorflow python pywrap_tensorflow_internal.py",第20行
import _pywrap_tensorflow_internal
ModuleNotFoundError:没有名为'_pywrap_tensorflow_internal'的模块

无法加载本机TensorFlow运行时。

请参阅https://www.tensorflow.org/install/errors

出于一些常见原因和解决方案。包括整个堆栈跟踪
请求帮助时,请在此错误消息上方。


1.使用Anaconda

Anaconda使用conda分布索引,类似于PyPI。 TensorFlow conda构建使用MKL(Intel Math Kernel Library)。 它没有AVX。

下载这里提到的Anaconda,并创建一个新的conda环境,如这里提到的。

运行此命令:

1
conda install tensorflow

2.使用tensorflow-windows-wheel repo构建。

此repo包含许多TensorFlow pip轮文件,这些文件是使用SSE而不是AVX构建的。 SSE构建运行没有任何编译错误。 使用repo中的此文件。

希望这可以帮助。