【问题标题】:Installed tensorflow, but pycharm ignores it安装了tensorflow,但是pycharm忽略了
【发布时间】:2017-12-19 17:07:08
【问题描述】:

我通过(Joshua 的回答)安装了 tensorflow: 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:没有名为“tensorflow”的模块

有什么想法吗?

【问题讨论】:

    标签: python tensorflow pycharm


    【解决方案1】:

    只需从项目设置中安装 tensorflow。你不需要 anaconda。

    【讨论】:

    • nb。在 PyCharm 中访问项目解释器:文件 |设置 |项目口译员
    • 我认为没有那个选项了。可惜这些ide都不能正常工作。
    【解决方案2】:

    当你创建一个新项目时,你应该选择 Anaconda 的环境作为 python Interpreter。

    【讨论】:

    • 谢谢,如果我用pip安装其他包会不会有问题?
    【解决方案3】:

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

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

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

    【讨论】:

      【解决方案4】:

      我有类似的问题(我在 Windows 10 中使用 pycharm 2018 3.5) 我在终端中使用了(venv) D:\&gt;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 6-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*

      解决了!!!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-12-30
        • 1970-01-01
        • 2017-04-06
        • 2017-02-10
        • 2018-10-29
        • 1970-01-01
        • 2013-03-17
        • 2019-06-12
        相关资源
        最近更新 更多