已安装 tensorflow,但 pycharm 忽略它 [英] Installed tensorflow, but pycharm ignores it

查看:52
本文介绍了已安装 tensorflow,但 pycharm 忽略它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过(Joshua 的回答)安装了 tensorflow:如何在 anaconda python 3.6 上安装 tensorflow如果我在 cmd 中测试它:

I installed tensorflow by(answer from Joshua): how to install tensorflow on anaconda python 3.6 If I test it in cmd:

D:\>python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC 
v.1
900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.  
>>> import tensorflow
>>> hello = tf.constant('Hello, TensorFlow!')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    NameError: name 'tf' is not defined
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-07-14 16:21:53.235367: W d:\build\tensorflow\tensorflow-
r1.2\tensorflow\cor
e\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled 
to us
e SSE instructions, but these are available on your machine and could speed 
up C
PU computations.
2017-07-14 16:21:53.508199: W d:\build\tensorflow\tensorflow-
r1.2\tensorflow\cor
e\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled 
to us
e SSE2 instructions, but these are available on your machine and could speed 
up
CPU computations.
2017-07-14 16:21:53.511766: W d:\build\tensorflow\tensorflow-
r1.2\tensorflow\cor
e\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled 
to us
e SSE3 instructions, but these are available on your machine and could speed 
up
CPU computations.
2017-07-14 16:21:53.515734: W d:\build\tensorflow\tensorflow-
r1.2\tensorflow\cor
e\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled 
to us
e SSE4.1 instructions, but these are available on your machine and could 
speed u
p CPU computations.
2017-07-14 16:21:53.517818: W d:\build\tensorflow\tensorflow-
r1.2\tensorflow\cor
e\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled 
to us
e SSE4.2 instructions, but these are available on your machine and could 
speed u
p CPU computations.
>>> print(sess.run(hello))
b'Hello, TensorFlow!'

所以这应该没问题......但是如果我尝试在pycharm中重复这个测试(即使在我重新启动pycharm之后):ModuleNotFoundError: 没有名为tensorflow"的模块

So this shoulb be ok....but if I try t repeat this test in pycharm(even after I restarted pycharm): ModuleNotFoundError: No module named 'tensorflow'

知道为什么吗?

推荐答案

你应该在pycharm上使用conda的虚拟环境

You should use conda's virtual environment on pycharm

转到文件,默认设置,然后在项目解释器下选择 anaconda 一个.

Go to File, Default Setting and under project interpreter select the anaconda one.

如果您使用 pip 安装软件包,请确保 pip 指向正确的 python 实例.

If you use pip to install packages, be sure that pip is pointing towards the right python instance.

这篇关于已安装 tensorflow,但 pycharm 忽略它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆