我安装张量流(约书亚回答): how to install tensorflow on anaconda python 3.6 如果我在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:没有名为&#39; tensorflow&#39;
的模块任何想法为什么?
答案 0 :(得分:8)
答案 1 :(得分:1)
您应该在pycharm上使用conda's
虚拟环境
转到文件,默认设置,然后在项目解释器下选择anaconda one。
如果使用pip
安装软件包,请确保pip
指向正确的python实例。
答案 2 :(得分:1)
答案 3 :(得分:0)
我有类似的问题(我在Windows 10中使用pycharm 2018 3.5)
我在终端中使用(venv) D:\>pip install tensorflow --upgrade
更新了张量流
并等待(这很耗时)获取此信息:
成功安装了absl-py-0.7.1 astor-0.7.1 gast-0.2.2 grpcio-1.19.0 h5py-2.9.0 keras-applications-1.0.7 keras-preprocessing-1.0.9 markdown-3.0。 1模拟2.0.0 numpy-1.16.2 pbr-5。 1.3 protobuf-3.7.0六-1.12.0 tensorboard-1.13.1 tensorflow-1.13.1 tensorflow-estimator-1.13.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.33.1 *
解决了!!
答案 4 :(得分:-3)
工作完美,错误消失了! Pycharm