报错:AttributeError: 'module' object has no attribute 'xxx'

问题: import pysam的时候,

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    import pysam
  File "/home/wangjing/Downloads/NA12878/image/pysam.py", line 10, in <module>
AttributeError: 'module' object has no attribute 'AlignmentFile'

可能1. mutual top-level imports

http://stackoverflow.com/questions/1250103/attributeerror-module-object-has-no-attribute

可能2. py文件命名

http://lovesoo.org/python-script-error-attributeerror-module-object-has-no-attribute-solve-method.html

  • 命名py脚本时,不要与python预留字,模块名等相同**
  • 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件;在已经生成.pyc文件的情况下,若代码不更新,运行时依旧会走pyc,所以要删除.pyc文件),重新运行代码;或者找一个可以运行代码的环境,拷贝替换当前机器的.pyc文件即可**
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容