Pycharm不会导入软件包,而iPython会导入

时间:2019-03-02 18:44:11

标签: python pycharm windows-10

我正在尝试在Pycharm中运行以下python脚本:

import tensorflow as tf

hello = tf.constant("hello TensorFlow!")
sess=tf.Session()
print(sess.run(hello))

但是最后一条语句出现错误:

  

AttributeError:类型对象'h5py.h5r.Reference'没有属性'__ reduce_cython __'

但是同一脚本可以在iPython上正常执行,因此我怀疑问题出在Pycharm。

我在Pycharm中设置了指向conda env的正确解释器,此外,我发现similar problem并手动将LD_LIBRARY_PATH设置为C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64

这也没有做。

有人知道我还要做什么吗?

我正在使用:

  • Python 3.6
  • Pycharm 2018.3.5(社区版)
  • Windows 10

1 个答案:

答案 0 :(得分:1)

将h5py从预先安装了tensorflow的2.9.0降级到2.8.0就可以解决问题。

我不知道这是否是最好的解决方案,但现在它可以解决问题。