ImportError: No module named tensorflow in Spyder

Viewed 10348

This one is a famous question but int his scenario it's different and I couldn't find a solution which satisfy my problem. However this is it. I installed Python and Anaconda and Tensorflow in my computer like Tensorflow website describes.

And I installed it correctly and even tried example which provides by the Tensorflow website to check whether the Tensorflow working and it was succeeded. It runs in Anaconda prompt, Python prompt and python IDLE without a problem.

But when I try a script in Spyder and runs it in python console or ipython console, it gives me following error.

runfile('C:/Users/home/.spyder-py3/temp.py', wdir='C:/Users/home/.spyder-py3')
Traceback (most recent call last):

File "<ipython-input-2-4aa1bb797551>", line 1, in <module>
runfile('C:/Users/home/.spyder-py3/temp.py', wdir='C:/Users/home/.spyder-py3')

File "C:\Users\home\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)

File "C:\Users\home\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/home/.spyder-py3/temp.py", line 1, in <module>
import tensorflow as tf

ModuleNotFoundError: No module named 'tensorflow'

I don't know why is that and couldn't find a solution.

2 Answers

I know it's an old question, but I found it useful to mention another way to solve it as follows:

  1. Install the tensorflow using conda, as described here, including the creation of a new environment...(You already mentioned that you did, but I'm adding it here as a reference for any new comer).
  2. From Anaconda Navigator, go to the top and select your new environment that you just created in the step1....(inspired by Rimma post on this question).
  3. Click install first for the application you want to install(Spyder or Jupyter..etc) then Click launch the application.
  4. Verify the installation by trying "import tensorflow as tf, as an example).

enter image description here

Related