我使用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上运行。
答案 0 :(得分:1)
激活virtualenv
仅重定向<virtualenv_root>/bin
下的命令。 pythonw
不在其中,您需要调用python
。 A stub for pythonw
is only created in Windows and Cygwin