AttributeError:'module'对象没有h5py的属性'File'

时间:2017-03-04 07:15:28

标签: python h5py

所以这是我的代码的开头:

#!/usr/bin/python

import h5py
f = h5py.File("/data/vera/run-2/hdfaa.001","r")

当我运行它时,它在主目录中运行良好。但是当我在主目录中的目录中运行它时,会出现错误:

Traceback (most recent call last):
File "h5py.py", line 3, in <module>
import h5py
File "/.../h5py.py", line 5, in <module>
f = h5py.File("/...","r")
AttributeError: 'module' object has no attribute 'File'

当我使用python解释器的IPython时,它可以导入库并具有属性h5py.File。但是一旦我解释了脚本,解释器就不能再导入h5py库了。删除文件后,它再次正常工作。

我已经使用解释器检查我的脚本,脚本应该没有任何问题。

因为我对python很新,所以我不知道哪里出错了。

1 个答案:

答案 0 :(得分:-1)

这对我有用:

  • 卸载h5py:pip uninstall h5py
  • 安装h5py:pip install h5py

实际上,我检查了已经存在的h5py软件包,它对我来说似乎已损坏。所以我做了显而易见的事情,瞧,它起作用了!

相关问题