Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use tensorflow on pyCharm

I am new to Deep Learning and I have just installed tensorflow on my Mac, however, there are some problems.

I am sure I installed successfully because I can run tensorflow on Terminal using python 3.5

import tensorflow as tf  
node1 = tf.constant(3.0, tf.float32)  
node2 = tf.constant(4.0)  # also tf.float32 implicitly  
print(node1, node2)  

there is an output on my bash

Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0", shape=(), dtype=float32)

However, when I run import tensorflow as tf on Python Console of PyCharm. A problem occurred:

>>> import tensorflow as tf
ImportError: No module named 'tensorflow'
like image 231
Kang Avatar asked Feb 04 '23 22:02

Kang


1 Answers

I just went through this a few days ago after switching to PyCharm. You have to select the right Project Interpreter so it can find the Python installation that includes Tensorflow. In the menu go to PyCharm->Preferences and under the section Project: PyCharm on the left select Project Interpreter. In my case, I select 3.5.2 (~/anaconda/bin/python) because there's where my Tensorflow seems to reside. Whatever versions you select, scroll through the window at the bottom to make sure you see Tensorflow listed as a Package.

IMPORTANT: in my case it seems that once you OK this, it takes a while for PyCharm to digest? Because for a while the 'Run' button is greyed out and you can't run your program. Took me a while to figure what I'm doing wrong, but looks like you just need to give it sometime and it picks it up and the Run button goes back to green. Hope this works for you...

I am using the Community Edition, for what it's worth...

like image 59
VS_FF Avatar answered Feb 07 '23 10:02

VS_FF