【问题标题】:Error when importing TensorFlow in Python on Windows在 Windows 上用 Python 导入 TensorFlow 时出错
【发布时间】:2016-05-18 13:40:37
【问题描述】:

我正在运行 Python 2.7.10,并且使用 pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl 成功安装了 TensorFlow。

当我运行 python 解释器并尝试导入 tensorflow 模块时,我收到以下错误:

>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\__init__.py", line 22, in <module>
    from tensorflow.python.client.client_lib import *
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\client\client_lib.py", line 35, in <module>
    from tensorflow.python.client.session import InteractiveSession
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\client\session.py", line 11, in <module>
    from tensorflow.python import pywrap_tensorflow as tf_session
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Users\Or\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
    import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow

【问题讨论】:

    标签: python pip tensorflow


    【解决方案1】:

    你可以使用pip来安装tensorflow

    pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl
    

    如果你想在 windows 上安装,你必须有 python3.5 x64 位,并且你需要安装 Visual C++ 2015 redistributable (x64 version) 才能导入 tensorflow

    【讨论】:

    • 非常感谢。我安装了 tensorflow,版本是 0.12.1。但还是有问题。在这个答案中安装一个解决了这个问题。
    【解决方案2】:

    从输出中的路径来看,您似乎正在尝试在 Windows 上运行 TensorFlow。您安装的软件包是 TensorFlow 的 Mac OS X 二进制分发包。

    不幸的是,Windows 是not currently supported by TensorFlow,在其构建系统(Bazel)添加 Windows 支持之前不太可能得到支持。在 GitHub issueunsupported contribution that builds TensorFlow using CMake on Windows 上有一些关于 Windows 版本进展的讨论。

    【讨论】:

      猜你喜欢
      • 2019-05-02
      • 2014-02-16
      • 1970-01-01
      • 2020-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多