显示是版本不兼容,需要更新库吗
来源:1-1 课程介绍
weixin_慕慕2193927
2025-07-30 21:49:07
pdfkit pydocx PyDocX html = PyDocX.to_html() f = (, ) f.write(html) f.close() pdfkit.from_string(html, )
结果显示是什么原因
if not isinstance(args, collections.Hashable): ^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'collections' has no attribute 'Hashable'
1回答
好帮手慕小猿
2025-07-31
同学,你好!报错说collections没有Hashable 这个属性,但collections.Hashable 是存在的。在 Python 3.3 及以后的版本中,它被移动到了 collections.abc 模块中。
解决方法:
1、同学找到报错的memoize.py。memoize.py文件位置在同学提供报错信息的上一行就可以看到,比如老师的文件位置是\Lib\site-packages\pydocx\util\memoize.py。打开memoize.py将报错信息if not isinstance
(args,collections.Hashable)改为if not isinstance(args,collections.abc.Hashable)
2、将memozie.py第一行的 import collections 改为 import collections.abc 。保存memoize.py并重新运行程序看能否成功
祝学习愉快~
相似问题
回答 1
回答 1