Robert Valencia
Robert Valencia

Reputation: 1752

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.

Upvotes: 0

Views: 547

Answers (1)

ivan_pozdeev
ivan_pozdeev

Reputation: 36028

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.

Upvotes: 1

Related Questions