bash 在 pyCharm 上使用 tensorflow
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42712237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
use tensorflow on pyCharm
提问by Kang
I am new to Deep Learning and I have just installed tensorflow on my Mac, however, there are some problems.
我是深度学习的新手,我刚刚在我的 Mac 上安装了 tensorflow,但是,存在一些问题。
I am sure I installed successfully because I can run tensorflow on Terminal using python 3.5
我确定我安装成功,因为我可以使用 python 3.5 在终端上运行 tensorflow
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
我的 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
在 PyCharm 的 Python 控制台上运行时。出现了一个问题:
>>> import tensorflow as tf
ImportError: No module named 'tensorflow'
回答by VS_FF
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.
几天前,我在切换到 PyCharm 后刚刚经历了这个。您必须选择正确的项目解释器,以便它可以找到包含 Tensorflow 的 Python 安装。在菜单中转到 PyCharm->Preferences,然后在左侧的 Project: PyCharm 部分下选择 Project Interpreter。就我而言,我选择 3.5.2 (~/anaconda/bin/python) 因为我的 Tensorflow 似乎驻留在那里。无论您选择什么版本,滚动底部的窗口以确保您看到 Tensorflow 被列为一个包。
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...
重要提示:就我而言,似乎一旦你确定了这个,PyCharm 需要一段时间才能消化?因为有一段时间“运行”按钮是灰色的,您无法运行您的程序。我花了一段时间才弄清楚我做错了什么,但看起来你只需要在某个时候给它,它就会把它捡起来,运行按钮又变回绿色。希望这对你有用...
I am using the Community Edition, for what it's worth...
我正在使用社区版,因为它的价值...
回答by j3ffyang
I'm using PyCharm 2018.1.4 Community Edition on Fedora 28, and have TensorFlow 1.9.0 installed (through "sudo pip3 install --upgrade tensorflow"). Here is my step to load TensorFlow
我在 Fedora 28 上使用 PyCharm 2018.1.4 社区版,并安装了 TensorFlow 1.9.0(通过“sudo pip3 install --upgrade tensorflow”)。这是我加载 TensorFlow 的步骤
File > Settings > Project > Project Interpreter > Change to "/usr/bin/python3.6" in Project Interpreter, then the installed Package will be loaded and displayed.
File > Settings > Project > Project Interpreter > 在 Project Interpreter 中更改为“/usr/bin/python3.6”,则将加载并显示已安装的 Package。
Good luck.
祝你好运。