bug解决:AttributeError: module ‘collections‘ has no attribute “*”
背景
做二代宏基因组数据拼接时,spades.py调用报错。
具体报错如下:
Traceback (most recent call last):
File "/share/home/xiehs/bin/spades.py", line 659, in <module>
main(sys.argv)
File "/share/home/xiehs/bin/spades.py", line 599, in main
print_params(log, log_filename, command_line, args, cfg)
File "/share/home/xiehs/bin/spades.py", line 327, in print_params
print_used_values(cfg, log)
File "/share/home/xiehs/bin/spades.py", line 117, in print_used_values
dataset_data = pyyaml.load(open(cfg["dataset"].yaml_filename))
File "/share/home/xiehs/biosoft/SPAdes-3.15.3-Linux/share/spades/pyyaml3/__init__.py", line 72, in load
return loader.get_single_data()
File "/share/home/xiehs/biosoft/SPAdes-3.15.3-Linux/share/spades/pyyaml3/constructor.py", line 37, in get_single_data
return self.construct_document(node)
File "/share/home/xiehs/biosoft/SPAdes-3.15.3-Linux/share/spades/pyyaml3/constructor.py", line 46, in construct_document
for dummy in generator:
File "/share/home/xiehs/biosoft/SPAdes-3.15.3-Linux/share/spades/pyyaml3/constructor.py", line 398, in construct_yaml_map
value = self.construct_mapping(node)
File "/share/home/xiehs/biosoft/SPAdes-3.15.3-Linux/share/spades/pyyaml3/constructor.py", line 204, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/share/home/xiehs/biosoft/SPAdes-3.15.3-Linux/share/spades/pyyaml3/constructor.py", line 126, in construct_mapping
if not isinstance(key, collections.Hashable):
AttributeError: module 'collections' has no attribute 'Hashable'
解决方案
Python 3.10 版本 collections 将 等一些属性放到了 collections.abc 子模块下。所以会出现 collections’ has no attribute 的错误。
找到最后报错的文件,一般是报错出现的最后一个文件。更改collections.attr 为 collections.abc.attr。
/share/home/xiehs/biosoft/SPAdes-3.15.3-Linux/share/spades/pyyaml3/constructor.py文件中第126行
attr 为报错中没有的属性,新增.abc.问题就解决了。
- 本文标签: Linux python 宏基因组
- 本文链接: https://blog.voiceclouds.cn/article/79
- 版权声明: 本文由广州海琳信息技术有限公司原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权