关于使用Python-pptx第三模块创建PPT无法运行出现错误,请问错误出现在哪?该如何让这个程序正常运行?
源代码如下:
```python
from pptx import Presentation
from pptx.util import Inches
presentation=Presentation()
slide=presentation.slides.add_slide(presentation.slide_layout[0])
presentation.save("Python自动生成PPT.pptx")
运行结果如下:
C:\Users\燕双鹰\AppData\Local\Programs\Python\Python310\python.exe D:/pythonProject1/main.py
Traceback (most recent call last):
File "C:\Users\燕双鹰\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\compat\__init__.py", line 10, in <module>
Container = collections.abc.Container
AttributeError: module 'collections' has no attribute 'abc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\pythonProject1\main.py", line 1, in <module>
from pptx import Presentation
File "C:\Users\燕双鹰\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\__init__.py", line 14, in <module>
from pptx.api import Presentation # noqa
File "C:\Users\燕双鹰\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\api.py", line 15, in <module>
from .package import Package
File "C:\Users\燕双鹰\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\package.py", line 6, in <module>
from pptx.opc.package import OpcPackage
File "C:\Users\燕双鹰\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\opc\package.py", line 11, in <module>
from pptx.compat import is_string, Mapping
File "C:\Users\燕双鹰\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\compat\__init__.py", line 14, in <module>
Container = collections.Container
AttributeError: module 'collections' has no attribute 'Container'
进程已结束,退出代码为 1