导入tensorflow时出错;说缺少几个模块

时间:2018-05-02 09:13:25

标签: python windows python-3.x tensorflow

我根据给定here的说明在Windows 7(32位)中使用Anaconda安装了tensorflow。但是在尝试导入tensorflow时,我收到以下错误:

(tensorflow) C:\Users\h473>python
Python 3.5.5 |Anaconda, Inc.| (default, Apr  7 2018, 04:53:16) [MSC v.1900 32 bi
t (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_imp
ort_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [
dirname(__file__)])
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\imp.
py", line 297, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_imp
ort_helper
    import _pywrap_tensorflow_internal
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow.py", line 72, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_imp
ort_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [
dirname(__file__)])
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\imp.
py", line 297, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>

    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_imp
ort_helper
    import _pywrap_tensorflow_internal
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>>

我也尝试过这样安装:

pip install tensorflow

但这甚至没有安装张量流;它给出了以下错误:

Collecting tensorflow
  Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

请说明问题是什么以及如何解决。

1 个答案:

答案 0 :(得分:0)

这是Tensorflow安装页面上常见安装问题部分中发布的问题之一,也许您可​​以尝试链接SO问题中提供的解决方案。

至于pip安装不起作用,也许你应该尝试:python -m pip install tensorflow

希望这有帮助。