0

I followed the tutorial on Tensorflow's web site, when I type Pip3 list I can see Tensorflow 1.4 in the list but when I start the Python terminal I can't import it, it says that there is No module named 'tensorflow'

even when I type Pip3 show tensorflow I can notice that it exists

Veltzer Doron
  • 934
  • 2
  • 10
  • 31
HISI
  • 4,557
  • 4
  • 35
  • 51
  • 2
    Do you open the terminal with `Python3`? – Amos Egel Jan 08 '18 at 14:26
  • yes, I did, but I could not import tensorflow !! – HISI Jan 08 '18 at 14:28
  • 1
    in the terminal what do you get typing `import sys; sys.version_info` – Chris_Rands Jan 08 '18 at 14:29
  • @Chris_Rands this is the output : `sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)` – HISI Jan 08 '18 at 14:31
  • Can you locate the installation folder of the package? Is it contained in the output of `sys.path`? – Amos Egel Jan 08 '18 at 14:42
  • @AmosEgel what would you me I do for you exactly?? – HISI Jan 08 '18 at 14:44
  • I would suggest to do two things: 1. check the output of `import sys; sys.path` to see the python path (that is where python looks for modules) 2. see if the tensorflow package was indeed installed into one of these folders. – Amos Egel Jan 08 '18 at 14:50
  • 1
    `pip3 show tensorflow` shows where it's currently installed, part 2 of [above comment](https://stackoverflow.com/questions/48152279/tensorflow-wont-import-in-my-python#comment83283901_48152279) – Steve Jan 08 '18 at 14:51
  • @Steve Location: /usr/local/lib/python3.5/dist-packages – HISI Jan 08 '18 at 14:52
  • import sys; sys.path ['', '/root/anaconda/lib/python36.zip', '/root/anaconda/lib/python3.6', '/root/anaconda/lib/python3.6/lib-dynload', '/root/anaconda/lib/python3.6/site-packages'] – HISI Jan 08 '18 at 14:53
  • @Steve should move tensorflow directory or add its path to this one – HISI Jan 08 '18 at 15:15
  • It seems that your `pip3` refers to Python 3.5 whereas your `python3` refers to Python 3.6. See [this question](https://stackoverflow.com/questions/46820625/how-to-use-pip3-for-python-3-6-instead-of-python-3-5) for a discussion how this can be changed. – Amos Egel Jan 08 '18 at 15:29

1 Answers1

2

You have two versions of Python 3 installed simultaneously. pip3 installed the package to Python 3.5, but python3 opens a Python 3.6 session, where tensorflow is not among the installed packages.

In other words, the reason for your problem is a mismatch between the pip3 version and python3 version.

This question adresses how to change this conflict. You can either modify the $PATH variable such that python3 also points to Python 3.5, or uninstall one of the two python versions.

Amos Egel
  • 937
  • 10
  • 24