简体   繁体   中英

VirtualEnv TensorFlow installation validation with “ImportError: No module named tensorflow” when running pythonw

I installed TensorFlow on a virtual environment using the steps provided from the TensorFlow installation page for Mac OS X:

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

When I try to verify that tensorflow was succesfully installed, I get an import error:

(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

I double checked by executing pip list , and it shows that tensorflow (1.1.0) was indeed installed. My system is running on macOS Sierra.

Activating virtualenv only redirects commands that exist under <virtualenv_root>/bin . pythonw is not among them, you need to invoke python instead. A stub for pythonw is only created in Windows and Cygwin .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM