Jerry Bai
Jerry Bai

Reputation: 51

Running “import tensorflow” on Mac generates "No module named tensorflow" error

Actually I already installed tensorflow by using

$ pip install tensorflow

and it works well when I use

$ python
Python 2.7.15 (default, Jul 23 2018, 21:27:06) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import tensorflow
>>>

but when I use python3 on command line

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>> 

it shows an error, and it shows the same error when I use IDLE

Upvotes: 2

Views: 8454

Answers (1)

Adil Basheer
Adil Basheer

Reputation: 11

use

pip3 install tensorflow

pip installs to default python directory. pip3 installs to python3

Upvotes: 1

Related Questions