使用pptx的Presentation提取pptx中的文字,同样的代码,pythonIDE正常出结果,slime直接报错。
from pptx import Presentation
pptx = Presentation('huanbaoyuan.pptx')
for slide in pptx.slides:
for shape in slide.shapes:
if shape.has_text_frame:
text_frame = shape.text_frame
for paragraph in text_frame.paragraphs:
print(paragraph.text)
Traceback (most recent call last):
File "C:\Users\SCGF\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 "C:\Users\SCGF\AppData\Roaming\Sublime Text\Packages\User\songsPythonFiles\pptx_test\pptx_test.py", line 1, in <module>
from pptx import Presentation
File "C:\Users\SCGF\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\__init__.py", line 14, in <module>
from pptx.api import Presentation # noqa
File "C:\Users\SCGF\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\api.py", line 15, in <module>
from .package import Package
File "C:\Users\SCGF\AppData\Local\Programs\Python\Python310\lib\site-packages\pptx\package.py", line 6, in <module>
from pptx.opc.package import OpcPackage
File "C:\Users\SCGF\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\SCGF\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'
[Finished in 1.2s]
slime version:Build 4126
pythonIDE shell version:3.10.0
python-pptx version:0.6.21IT技术精选文摘
lxml 4.7.1
Pillow 9.0.0
XlsxWriter 3.0.2
一直用slime学python,希望它可以正常