VirtualEnv TensorFlow安装验证" ImportError:没有名为tensorflow的模块"在运行pythonw时

时间:2017-04-27 01:23:57

标签: python macos tensorflow virtualenv

我使用Mac OS X的TensorFlow安装页面提供的步骤在虚拟环境中安装了TensorFlow:

$ sudo easy_install pip
$ sudo pip install --upgrade virtualenv
$ virtualenv --system-site-packages ~/tensorflow
$ source ~/tensorflow/bin/activate
(tensorflow)$ pip install --upgrade tensorflow

当我尝试验证成功安装了tensorflow时,我收到导入错误:

(tensorflow)$ pythonw
Python 2.7.13 (default, Mar  3 2017, 20:38:41)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow

我通过执行pip list进行了双重检查,并显示确实安装了tensorflow (1.1.0)。我的系统在macOS Sierra上运行。

1 个答案:

答案 0 :(得分:1)

激活virtualenv仅重定向<virtualenv_root>/bin下的命令。 pythonw不在其中,您需要调用pythonA stub for pythonw is only created in Windows and Cygwin