【问题标题】:cannot run tensorflow in windows 10无法在 Windows 10 中运行 tensorflow
【发布时间】:2018-01-31 23:00:46
【问题描述】:

我使用 cmd 命令在我的 windows 10 上成功安装了 tensorflow:

pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.0-py3-none-any.whl

但是,当我使用 PyCharm 运行一个简单的代码时,例如:

 import tensorflow as tf
 node1 = tf.constant(3.0, dtype=tf.float32)
 node2 = tf.constant(4.0) # also tf.float32 implicitly
 print(node1, node2)

我在控制台上收到以下错误:

  Traceback (most recent call last):
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\pywrap_tensorflow.py", line 18, in 
  swig_import_helperfp, pathname, description = 
  imp.find_module('_pywrap_tensorflow', [dirname(__file__)])
  File "C:\Users\Name\Desktop\Desktop\lib\imp.py", line 296, in find_module
  raise ImportError(_ERR_MSG.format(name), name=name)
  ImportError: No module named '_pywrap_tensorflow'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\__init__.py", line 66, in <module>
  from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
  _pywrap_tensorflow = swig_import_helper()
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\pywrap_tensorflow.py", line 20, in 
  swig_import_helper
  import _pywrap_tensorflow
  ModuleNotFoundError: No module named '_pywrap_tensorflow'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
  File "C:/Users/Name/Desktop/Desktop/ML/tfbasics.py", line 1, in <module>
  import tensorflow as tf
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\__init__.py", line 24, in <module>
  from tensorflow.python import *
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\__init__.py", line 72, in <module>
  raise ImportError(msg)
  ImportError: Traceback (most recent call last):
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\pywrap_tensorflow.py", line 18, in 
  swig_import_helper
  fp, pathname, description = imp.find_module('_pywrap_tensorflow', 
  [dirname(__file__)])
  File "C:\Users\Name\Desktop\Desktop\lib\imp.py", line 296, in find_module
  raise ImportError(_ERR_MSG.format(name), name=name)
  ImportError: No module named '_pywrap_tensorflow'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\__init__.py", line 66, in <module>
  from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
   _pywrap_tensorflow = swig_import_helper()
  File "C:\Users\Name\Desktop\Desktop\lib\site-
  packages\tensorflow\python\pywrap_tensorflow.py", line 20, in 
  swig_import_helper
  import _pywrap_tensorflow
  ModuleNotFoundError: No module named '_pywrap_tensorflow'

我研究了网络以修复此错误,但发现相互矛盾的结果无济于事。任何人都可以指出为什么会出现这个错误?

【问题讨论】:

  • 请大家帮忙!!

标签: python-3.x machine-learning tensorflow


【解决方案1】:

我不知道你为什么要在 Windows 上运行 Mac 时使用它

pip3 安装 --upgrade https://storage.googleapis.com/tensorflow/ma​​c/cpu/tensorflow-1.0.0-py3-none-any.whl

来自手册

发出适当的命令以在您的 conda 中安装 TensorFlow 环境。要安装仅 CPU 版本的 TensorFlow,请输入 以下命令:

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp35-cp35m-win_amd64.whl 要安装 TensorFlow 的 GPU 版本,请输入以下命令 (单行):

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.3.0-cp35-cp35m-win_amd64.whl

也请不要忘记

TensorFlow 仅支持 Windows 上的 Python 3.5.x 版本。注意 Python 3.5.x 自带 pip3 包管理器,就是程序 您将用于安装 TensorFlow。

【讨论】:

猜你喜欢
  • 2017-06-25
  • 1970-01-01
  • 1970-01-01
  • 2021-02-24
  • 2015-11-02
  • 2018-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多