Robert Valencia Robert Valencia - 1 year ago 305
Python Question

VirtualEnv TensorFlow instalation validation with ImportError: No module named tensorflow

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download