0

I have successfully installed tensorflow on my windows machine via Anaconda. It worked well in my commend prompt, where I am able to import tensorflow and run the hello world program. However, when I try to do it in my intellij-idea, it gives the "ModuleNotFoundError: No module named 'tensorflow'" error. What configuration must I set to get tensorflow to work in my intellij IDE?

Howell Pan
  • 53
  • 6
  • Is there any special reason you don't use pycharm instead? – Eypros Nov 30 '17 at 08:34
  • no particular reason, just am used to intellij from my java days. Would this just work in pycharm? – Howell Pan Nov 30 '17 at 19:54
  • I am not familiar with intellij with python (via plugin I guess). Your error message suggest that it cannot find tensorflow. On interactive mode can you import it? Are you using virtual env? – Eypros Dec 01 '17 at 07:27
  • it works find on commend shell. the question really is how to enable interactive mode or virtual env on intellij. – Howell Pan Dec 01 '17 at 17:52
  • then make the right question: https://stackoverflow.com/questions/20877106/using-intellijidea-within-an-existing-virtualenv – Eypros Dec 04 '17 at 07:35

3 Answers3

1

Try using jupyter notebook or spyder.

But make sure to install them within your tensorflow enviornment.

So first use(in your command prompt)

 tensorflow activate

and then

conda install spyder
C Lu
  • 87
  • 8
1

I've installed tensorflow through Anaconda in global environment. I think you are familiar with "File -> Project Structure", just set SDK as the python.exe under the Anaconda install path (i.e. "D:\Anaconda3\python.exe") in all related tabs, you may need to click add button and select the file. Then I found it still not working. One last step:

Add the path of tensorflow in "SDKs -> classpath": Add the path of tensorflow in "SDKs -> classpath".

To get the path, you can run:

import tensorflow
tensorflow.__path__
Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
俞晨静
  • 11
  • 2
  • Thank you! your steps worked, (I had to un- and re-install numpy with `pip uninstall numpy` and `pip install numpy` in Anaconda and then the `ModuleNotFoundError` disappeared and the script executed succesfully. – a.t. Feb 24 '20 at 14:56
0

You can also fix the problem with intellij. Make sure you select the right SDK when you create the project. Make sure to select the "python.exe" file in your tensorflow enviornment created under Anaconda.

enter image description here

Also see Using IntellijIdea within an existing virtualenv

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
C Lu
  • 87
  • 8