<分区>
所以这是我的代码的开头:
#!/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 很陌生,所以我不知道哪里出了问题。