1

I am following this tensorflow tutorial https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#protobuf-installation-compilation and I am facing some problems when testing the installation.

I installed everything except the COCO API in the tutorial and I am running the object detection demo in jupyter right now. For some reason, I get an error inside the notebook which tells me that there is "No module named 'tensorflow'". Can I still click on Run All or does this error has to be fixed?

Thanks! :)

import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile

from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops

if StrictVersion(tf.__version__) < StrictVersion('1.12.0'):
  raise ImportError('Please upgrade your TensorFlow installation to v1.12.*.')

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
      4 import sys
      5 import tarfile
----> 6 import tensorflow as tf
      7 import zipfile
      8 

ModuleNotFoundError: No module named 'tensorflow'

Okay, for some reasons, I get this error now:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
     10 from collections import defaultdict
     11 from io import StringIO
---> 12 from matplotlib import pyplot as plt
     13 from PIL import Image
     14 

ModuleNotFoundError: No module named 'matplotlib'
truongvu3
  • 29
  • 4
  • Does this help? https://stackoverflow.com/questions/46568913/tensorflow-import-error-no-module-named-tensorflow – Renat Jul 02 '19 at 22:02
  • I do not really understand the solution in this thread. Does the ImportError('Please upgrade your TensorFlow installation to v1.12.*.') have something to do with it? – truongvu3 Jul 02 '19 at 22:14

1 Answers1

1

You might be facing the problem of a double version of Python installed on your computer. Jupyter is trying to compile the Tensorflow tutorial file but with the wrong kernel (which should be Python 3). The same happened to me when trying to run ipynb files in which Tensorflow was included.

So I would first recommend you to do the following:

  1. Check the output of this command in your command line:

    jupyter kernelspec list

  2. Then it should output something similar to this: (in case of Windows OS)

    python3 c:\python 3.6.8\share\jupyter\kernels\python3

  3. If you find "python2" or any other type of version, you should remove it manually or try by using the command :

    jupyter kernelspec remove python_wrong_version

Finally, if the problem is still there you can also check the link https://github.com/jupyter/notebook/issues/397 for further discussions.