Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tensorflow installation issues:ImportError: No module named tensorflow

environments: Ubuntu 14.04(64bit) Python2.7.11

Firstly, I installed tensorflow in the way of Virtualenz installation.

$ sudo apt-get install python-pip python-dev python-virtualenv
$ virtualenv --system-site-packages ~/tensorflow
$ source ~/tensorflow/bin/activate  
$export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp27-none-linux_x86_64.whl

$ pip install --upgrade $TF_BINARY_URL

and then, I test my installation and some issue appear. I know I didn't install tensorflow successfully. import tensorflow Traceback (most recent call last): File "", line 1, in ImportError: No module named tensorflow

import tensorflow as tf Traceback (most recent call last): File "", line 1, in ImportError: No module named tensorflow

I don't know how to solve the problem. Please help me, it cost me one day. I tried to uninstall tensorflow and then I installed in the way of pip installation. But I get the same error. The protocbuf is 3.1.0.

like image 205
wilsing Avatar asked Jan 15 '17 07:01

wilsing


People also ask

How do I fix No module named in TensorFlow?

The Python "ModuleNotFoundError: No module named 'tensorflow'" occurs when we forget to install the tensorflow module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install tensorflow command.


1 Answers

Are you running python in the same virtual environment you installed tensorflow in?

To access your tensorflow installation, you have to first "activate" the virtualenv in any new terminals, as follows:

source ~/tensorflow/bin/activate
python
import tensorflow as tf

If you run the above in a new terminal, does it solve your problem?

like image 129
gunan Avatar answered Oct 05 '22 04:10

gunan