Howell Pan
Howell Pan

Reputation: 53

cannot import tensorflow in intellij python file, on windows system

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?

Upvotes: 0

Views: 2549

Answers (3)

俞晨静
俞晨静

Reputation: 11

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__

Upvotes: 1

C Lu
C Lu

Reputation: 87

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

Upvotes: 0

C Lu
C Lu

Reputation: 87

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

Upvotes: 1

Related Questions