【问题标题】:(Tensorflow Flow Setup) ImportError: No module named tensorflow(Tensorflow Flow Setup) ImportError: No module named tensorflow
【发布时间】:2018-10-28 01:52:21
【问题描述】:

我无法使用 pip3、Python 3.6 和 mac Sierra v10.12.6 通过Tensorflow documentation 完成设置说明。

尝试验证安装结果如下:

Installing collected packages: protobuf, tensorflow
Successfully installed protobuf-3.5.2.post1 tensorflow-1.8.0
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

➜  python3.6 python
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
>>> import Tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Tensorflow
>>> import tensorflow-1.8.0 as tf
  File "<stdin>", line 1
    import tensorflow-1.8.0 as tf
                     ^
SyntaxError: invalid syntax

【问题讨论】:

  • 你在使用 virtualenv 吗?
  • 请发布pip3 -V的结果。
  • @ArjunAthreya 我无法安装 virtualenv。这是我第一次使用 Python 和 Tensorflow。我需要 virtualenv 才能在这个 codelab 上工作吗? codelabs.developers.google.com/codelabs/tensorflow-for-poets
  • 我看到你的问题已经解决了,但是在我看来,在未来,我强烈推荐使用 virtualenv,这样你就可以将你的环境和包与整个系统隔离开来(为了不安装一些系统宽的)。这将使事情变得更容易,尤其是在运行代码和需要多个具有不同包的项目时。

标签: python python-3.x macos tensorflow


【解决方案1】:

请注意,当您运行 python 时,您会得到 Python 2.7.10,这不是您安装 TensorFlow 库的版本。尝试运行 python3 或确保在导入 import tensorflow as tf 之前运行 Python-3x。

【讨论】:

  • 已修复!谢谢你,nuric。
猜你喜欢
  • 2017-05-30
  • 2016-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-10
相关资源
最近更新 更多