【问题标题】:Error when importing tensorflow; says several modules are missing导入tensorflow时出错;说缺少几个模块
【发布时间】:2018-05-02 09:13:25
【问题描述】:

我根据here 给出的说明在带有 Anaconda 的 Windows 7(32 位)中安装了 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

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

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

请提出问题所在以及如何解决。

【问题讨论】:

  • 可以添加pip install tensorflow的回溯吗?这显示什么错误?
  • @harshil9968 编辑了最后的问题详细信息以包含确切的错误。
  • gist.github.com/diarabit/17d9051f9505c9d554d8a7d0c2bc4eb1,尝试在您的系统上运行此脚本
  • @harshil9968 它给出了同样的错误,“错误:导入TensorFlow模块失败。”,还指出缺少tensorflow-gpu文件,但我不想要tensorflow-gpu,我想要只有 CPU 的 tensorflow。
  • 也升级你的 pip,下载 get-pip.py stackoverflow.com/questions/4750806/…

标签: python windows python-3.x tensorflow


【解决方案1】:

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

至于pip安装不灵,或许你应该试试:python -m pip install tensorflow.

希望这会有所帮助。

【讨论】:

  • 执行了本论坛提出的所有解决方案,错误仍然存​​在。
  • 可能是 32 位架构的问题,因为这个问题显示 link
  • 您可以查看这篇关于在 32 位 ARM 架构上设置 tensorflow 的帖子blog
猜你喜欢
  • 2019-02-13
  • 2017-09-08
  • 2021-03-04
  • 2018-06-22
  • 2020-11-03
  • 1970-01-01
  • 2022-07-03
  • 2020-05-01
  • 2012-08-08
相关资源
最近更新 更多