ImportError: No module named tensorflow - Can't install Tensorflow #5478

Closed
paralaxwombat opened this Issue Nov 8, 2016 · 21 comments

Comments

Projects
None yet
@paralaxwombat

paralaxwombat commented Nov 8, 2016

I am trying to install tensorflow on mac and it's giving me this error.

ImportError: No module named tensorflow

Here is what I have done in the terminal

`sudo easy_install pip

sudo easy_install --upgrade six
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py3-none-any.whl
sudo -H pip3 install --upgrade $TF_BINARY_URL`

After that I try to run python and tensorflow to check my installation. It doesn't work. I have spent 3 hours on the problem.

Here is another post about it. http://stackoverflow.com/questions/40472144/importerror-no-module-named-tensorflow-cant-install-tensorflow?noredirect=1#comment68200554_40472144

@aselle

This comment has been minimized.

Show comment
Hide comment
@aselle

aselle Nov 8, 2016

Member

Please consider these things:

  • What OS? We support El Capitan right now. Sierra hopefully soon.
  • Try a newer version than 0.9 which is quite old, perhaps 0.11rc2
  • Are there any errors on the pip install?
  • What version of python. Perhaps try the python 2 version if you have that as well. Show exactly what version of python you are actually running and what it spits out. For example...
$ python
Python 2.7.10 (default, Jul 30 2016, 18:31:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] 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 understand it is frustrating to spend 3 hours having trouble, but it is hard for us to help you when you do not provide detailed information. Thanks.

Member

aselle commented Nov 8, 2016

Please consider these things:

  • What OS? We support El Capitan right now. Sierra hopefully soon.
  • Try a newer version than 0.9 which is quite old, perhaps 0.11rc2
  • Are there any errors on the pip install?
  • What version of python. Perhaps try the python 2 version if you have that as well. Show exactly what version of python you are actually running and what it spits out. For example...
$ python
Python 2.7.10 (default, Jul 30 2016, 18:31:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] 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 understand it is frustrating to spend 3 hours having trouble, but it is hard for us to help you when you do not provide detailed information. Thanks.

@LeongKH

This comment has been minimized.

Show comment
Hide comment
@LeongKH

LeongKH Nov 26, 2016

Hi @aselle ,

THIS IS SOLVED, SEE BOTTOM COMMENT
I am having the same error too.
I am using EI Capitan 10.11.2

Here is what i did in my installation, no error during the installation:

$ sudo easy_install pip
$ sudo easy_install --upgrade six
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
$ sudo pip install --upgrade $TF_BINARY_URL

Here is my tensor flow information:

$ pip show tensorflow
Name: tensorflow
Version: 0.9.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires: protobuf, numpy, wheel, six

here is my protobuf information:

$ pip show protobuf
Name: protobuf
Version: 3.0.0b2
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Author: protobuf@googlegroups.com
Author-email: protobuf@googlegroups.com
License: New BSD License
Location: /usr/local/lib/python2.7/site-packages
Requires: setuptools, six

here is my six information:

$ pip show six
Name: six
Version: 1.10.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/local/lib/python2.7/site-packages
Requires:

Following is my python version:

$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensor flow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tensor flow
>>>

UPDATE: It seems that my pip is link to python 2.7.12 (previously installed via Homebrew). I uninstall everything, and reinstall to solve the issue

LeongKH commented Nov 26, 2016

Hi @aselle ,

THIS IS SOLVED, SEE BOTTOM COMMENT
I am having the same error too.
I am using EI Capitan 10.11.2

Here is what i did in my installation, no error during the installation:

$ sudo easy_install pip
$ sudo easy_install --upgrade six
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
$ sudo pip install --upgrade $TF_BINARY_URL

Here is my tensor flow information:

$ pip show tensorflow
Name: tensorflow
Version: 0.9.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires: protobuf, numpy, wheel, six

here is my protobuf information:

$ pip show protobuf
Name: protobuf
Version: 3.0.0b2
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Author: protobuf@googlegroups.com
Author-email: protobuf@googlegroups.com
License: New BSD License
Location: /usr/local/lib/python2.7/site-packages
Requires: setuptools, six

here is my six information:

$ pip show six
Name: six
Version: 1.10.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/local/lib/python2.7/site-packages
Requires:

Following is my python version:

$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensor flow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tensor flow
>>>

UPDATE: It seems that my pip is link to python 2.7.12 (previously installed via Homebrew). I uninstall everything, and reinstall to solve the issue

@prb12

This comment has been minimized.

Show comment
Hide comment
@prb12

prb12 Nov 27, 2016

Member

Closing.

Member

prb12 commented Nov 27, 2016

Closing.

@prb12 prb12 closed this Nov 27, 2016

@rezafarhadi

This comment has been minimized.

Show comment
Hide comment
@rezafarhadi

rezafarhadi Jan 28, 2017

I had the same issue with mac os.. this fixed the problem:
install brew
brew install python
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL

I had the same issue with mac os.. this fixed the problem:
install brew
brew install python
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL

@UkiDLucas

This comment has been minimized.

Show comment
Hide comment
@UkiDLucas

UkiDLucas Feb 1, 2017

If you use brew:

  • brew install python - installs 2.7
  • brew install python3 - installs 3.6
    in any case, you are not running optimal version for TensorFlow 3.5

Anyway,
$ python --version
Python 3.5.2 :: Continuum Analytics, Inc.

$ echo $TF_BINARY_URL
https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl

When running:
$ sudo pip3 install --ignore-installed --upgrade $TF_BINARY_URL

it looks like it installs everything 100%
$ conda list
...
tensorflow-gpu 0.12.1
...

but when running $ jupyter notebook
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

For Jupyter kernel to reflect changes in conda env (tensorflow), I had to set up the following:

$ source activate tensorflow
$ sudo pip install ipykernel
$ python -m ipykernel install --user --name tensorflow --display-name "conda env tensorflow"

my blog

UkiDLucas commented Feb 1, 2017

If you use brew:

  • brew install python - installs 2.7
  • brew install python3 - installs 3.6
    in any case, you are not running optimal version for TensorFlow 3.5

Anyway,
$ python --version
Python 3.5.2 :: Continuum Analytics, Inc.

$ echo $TF_BINARY_URL
https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl

When running:
$ sudo pip3 install --ignore-installed --upgrade $TF_BINARY_URL

it looks like it installs everything 100%
$ conda list
...
tensorflow-gpu 0.12.1
...

but when running $ jupyter notebook
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

For Jupyter kernel to reflect changes in conda env (tensorflow), I had to set up the following:

$ source activate tensorflow
$ sudo pip install ipykernel
$ python -m ipykernel install --user --name tensorflow --display-name "conda env tensorflow"

my blog

@lingfengchencn

This comment has been minimized.

Show comment
Hide comment
@lingfengchencn

lingfengchencn Feb 22, 2017

i had the same issue. and here is why it happen and how i fixed it in my issue:
env: anaconda (python 3.6)+mac ,
first ,i used :
$ pip3 install tensorflow
$ python
Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00)

import tensorflow as tf

ModuleNotFoundError: No module named 'tensorflow'

and then
$pip install tensorflow
$python
Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00)

import tensorflow as tf

i had the same issue. and here is why it happen and how i fixed it in my issue:
env: anaconda (python 3.6)+mac ,
first ,i used :
$ pip3 install tensorflow
$ python
Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00)

import tensorflow as tf

ModuleNotFoundError: No module named 'tensorflow'

and then
$pip install tensorflow
$python
Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00)

import tensorflow as tf

@gsanjeevkumar

This comment has been minimized.

Show comment
Hide comment
@gsanjeevkumar

gsanjeevkumar Mar 12, 2017

@LeongKH thanks this works for me!

@LeongKH thanks this works for me!

@saramelvin

This comment has been minimized.

Show comment
Hide comment
@saramelvin

saramelvin Apr 29, 2017

importing tensorflow using python3 instead of python 2.7 worked for me.

importing tensorflow using python3 instead of python 2.7 worked for me.

@KiselevMaxim

This comment has been minimized.

Show comment
Hide comment
@KiselevMaxim

KiselevMaxim Jun 13, 2017

pip3 install tensorflow
...
pip install tensorflow

thank you, it is works for me

pip3 install tensorflow
...
pip install tensorflow

thank you, it is works for me

@johndpope

This comment has been minimized.

Show comment
Hide comment
@johndpope

johndpope Aug 8, 2017

Contributor

some computer scientist lady recommended miniconda - and I haven't looked back.
Forget using pip/pip3 / use conda + conda environments. I can't recommend it more.
https://gist.github.com/johndpope/187b0dd996d16152ace2f842d43e3990

Contributor

johndpope commented Aug 8, 2017

some computer scientist lady recommended miniconda - and I haven't looked back.
Forget using pip/pip3 / use conda + conda environments. I can't recommend it more.
https://gist.github.com/johndpope/187b0dd996d16152ace2f842d43e3990

@andyhappy1

This comment has been minimized.

Show comment
Hide comment
@andyhappy1

andyhappy1 Aug 23, 2017

@UkiDLucas Thanks very much. That fixed it for me. I believe it's that you need iPython to make Python 2.7 work with Anaconda.

This fixed it for me:
$source activate tensorflow
$ sudo pip install ipykernel
$ python -m ipykernel install --user --name tensorflow --display-name "conda env tensorflow"

@UkiDLucas Thanks very much. That fixed it for me. I believe it's that you need iPython to make Python 2.7 work with Anaconda.

This fixed it for me:
$source activate tensorflow
$ sudo pip install ipykernel
$ python -m ipykernel install --user --name tensorflow --display-name "conda env tensorflow"

@armotodo

This comment has been minimized.

Show comment
Hide comment
@armotodo

armotodo Sep 19, 2017

chunchuria
umbrella

chunchuria
umbrella

@armotodo

This comment has been minimized.

Show comment
Hide comment
@armotodo

armotodo Sep 19, 2017

a si
como
no
me
inco

a si
como
no
me
inco

@Afrogeek254

This comment has been minimized.

Show comment
Hide comment
@Afrogeek254

Afrogeek254 Oct 28, 2017

Hi i have the same issue when trying to run tensorflow in my windows 10
when I run pip show cmd this is what is displayed
C:>pip show tensorflow
Name: tensorflow
Version: 1.3.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: c:\program files\python36\lib\site-packages
Requires: six, wheel, tensorflow-tensorboard, numpy, protobuf

when prompt my python shell and try to import tensorflow

it gives me this error

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

kindly assist

Hi i have the same issue when trying to run tensorflow in my windows 10
when I run pip show cmd this is what is displayed
C:>pip show tensorflow
Name: tensorflow
Version: 1.3.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: c:\program files\python36\lib\site-packages
Requires: six, wheel, tensorflow-tensorboard, numpy, protobuf

when prompt my python shell and try to import tensorflow

it gives me this error

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

kindly assist

@renying

This comment has been minimized.

Show comment
Hide comment
@renying

renying Dec 19, 2017

i had the same issue.
i installed two version of python 2.7 and 3.5
tensorflow installs in python2.7

my default python version is 3.5
so if I type: python
Python 3.5.3 (default, Dec 7 2017, 09:41:57)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.

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

but if I type: python2.7
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import tensorflow as tf

It`s OK

so check your python version.
It will help

renying commented Dec 19, 2017

i had the same issue.
i installed two version of python 2.7 and 3.5
tensorflow installs in python2.7

my default python version is 3.5
so if I type: python
Python 3.5.3 (default, Dec 7 2017, 09:41:57)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.

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

but if I type: python2.7
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import tensorflow as tf

It`s OK

so check your python version.
It will help

@emelendez89

This comment has been minimized.

Show comment
Hide comment
@emelendez89

emelendez89 Jan 2, 2018

@Afrogeek254 I also stumbled on this problem, and fixed it by changing python version. (Win10 x64)
Funny thing is that the first version I tried is the one "supported" by TF as said in the documentation (used the link in the page for 3.6.x 64 which was 3.6.2).
Didn't want to find a workaround, and ended up installing 3.5.2 (also linked in the installation docs)

emelendez89 commented Jan 2, 2018

@Afrogeek254 I also stumbled on this problem, and fixed it by changing python version. (Win10 x64)
Funny thing is that the first version I tried is the one "supported" by TF as said in the documentation (used the link in the page for 3.6.x 64 which was 3.6.2).
Didn't want to find a workaround, and ended up installing 3.5.2 (also linked in the installation docs)

@hollykunge

This comment has been minimized.

Show comment
Hide comment
@hollykunge

hollykunge Jan 18, 2018

卧槽 解决了 很给力!

卧槽 解决了 很给力!

@nickkong

This comment has been minimized.

Show comment
Hide comment
@nickkong

nickkong Mar 16, 2018

わあ、解決し、すごい

わあ、解決し、すごい

@devinhee

This comment has been minimized.

Show comment
Hide comment
@devinhee

devinhee Jun 7, 2018

I create a virtual environment, when I run some codes ,give the same Error. And I reinstall tensorflow , but it doesn't work

devinhee commented Jun 7, 2018

I create a virtual environment, when I run some codes ,give the same Error. And I reinstall tensorflow , but it doesn't work

@cww97

This comment has been minimized.

Show comment
Hide comment
@cww97

cww97 Jun 15, 2018

I have another stituation, I have succssfully installed tensorflow on my mac, and a function which uses tensorflow's model can run by its own. However, when I import this fuction in Django, the first line is 'import tensorflow as tf', error: ModuleNotFoundError: No module named 'tensorflow'.. wtf

cww97 commented Jun 15, 2018

I have another stituation, I have succssfully installed tensorflow on my mac, and a function which uses tensorflow's model can run by its own. However, when I import this fuction in Django, the first line is 'import tensorflow as tf', error: ModuleNotFoundError: No module named 'tensorflow'.. wtf

@devinhee

This comment has been minimized.

Show comment
Hide comment
@devinhee

devinhee Jun 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment