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

问题: import pysam的时候,

Traceback (most recent call last):
  File "test.py", line 2, in 
    import pysam
  File "/home/wangjing/Downloads/NA12878/image/pysam.py", line 10, in 
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文件即可**

你可能感兴趣的:(报错:AttributeError: 'module' object has no attribute 'xxx')