我尝试启动
python-pptx
,但出现错误:
AttributeError: module 'collections' has no attribute 'Container'
in File "...\lib\site-packages\pptx_init_.py", line 14
使用Python 3.10、python-pptx (0.6.21)、lxmx (4.6.3)。
这是 Python 3.10 的一个已知问题,如本 issue 中所述。解决方法是导入两个模块
collections
和
导入之前collections.abc
pptx
。例如:
import collections
import collections.abc
from pptx import Presentation
这应该可以解决此错误
我将python 3.10更改为python 3.9,问题解决了。