2017-07-14 105 views
0

我安装tensorflow通过(回答约书亚): how to install tensorflow on anaconda python 3.6 如果我测试它在CMD:安装tensorflow,但pycharm忽略它

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!' 

所以这shoulb是确定....但如果我尝试t在pycharm中重复此测试(即使重新启动pycharm后): ModuleNotFoundError:没有名为'tensorflow'的模块

任何想法为什么?

回答

1

您应该使用在pycharm

转到conda's虚拟环境中文件,默认设置下的项目解释选择蟒蛇之一。

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

1

当你创建一个新的项目时,你应该选择Anaconda的环境作为Python解释器。 enter image description here

+0

谢谢,如果我使用pip安装其他软件包,会出现问题吗? – econ

0

只从项目设置安装tensorflow。你不需要水蟒。

enter image description here

-1

它工作完美,错误消失了! Pycharm