0
votes

I am trying to install Tensorflow on a Windows 7 laptop in order to use jupyter notebook to play around with the object detection notebook in Github. I am facing this error:

ImportError Traceback (most recent call last) in () 4 import sys 5 import tarfile ----> 6 import tensorflow as tf 7 import zipfile 8

ImportError: No module named tensorflow

I am getting the above error when I start the Jupyter Notebook from inside the Conda environment in Windows 7. I have installed Python 3.5.4 & within conda environment, tensorflow as well.

I am also getting ... not recognized as an internal/external... for $ command while giving $ python and sometimes also for pip3 I have included several file paths in Environment Variables. Can you please suggest me what to do. I am using the Conda env as I feel I have a problem in having Windows Service Pack 1.

2
Are you importing the tensorflow library into your Jupyter notebook? - Nathan
Thanks Nathan. Could you please tell me how to do that? All I am trying is: import tensorflow as tf -- here am getting the error msg: ImportError: No module named tensorflow - fim

2 Answers

0
votes

Make sure your Tensorflow folder is somewhere that the environment will look, such as [Python install directory]/Lib/Site-packages

0
votes

If you are using Anaconda to manage your installation, be aware that it is community supported and not officially supported by Google. Google has a detailed guide on how to install Tensorflow on Windows as well as how to validate the installation. Follow their steps carefully and be aware you may need to start the process over if you miss a step.

1) Make sure you start with a clean Conda Environment for Tensorflow. You will need to specifiy Python version 3.5. You can do this by running the command,

C:> conda create -n tensorflow python=3.5

2) Once the new Conda environmnet is created, activate it. This step is commonly overlooked.

C:> activate tensorflow
(tensorflow)C:>  # The Conda environment may appear before the drive letter

3) With the Tensorflow environment active, issue the pip command to install the appropriate Tensorflow version. To keep things simple, I assume you will be installing the CPU version. If you need the GPU version, refer to the Google guide since there are other things you will need to do in order to set up the NVIDIA drivers.

(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow 

Note the flags included on the pip install command.

To make sure that Tensorflow is installed properly, validate the installation. Do this by double checking that the Tensorflow Conda environment is active and starting a python console. Once the console is running type the following sample program, suggested by Google's guide.

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

If you are new to Tensorflow, this code may not make sense. What it does is import the Tensorflow library, assign a variable called "hello" to a Tensorflow constant tensor. Tensorflow is a library designed to operate on Tensor data objects. The next line initiates a Tensorflow session which loads all the data objects. The final line prints the output of Session.run() on the hello constant object. If everything is set up correctly you should see

Hello, TensorFlow!

output on the console. If you don't, check to common installation issues included in Google's Tensorflow install guide.