scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.35k stars 510 forks source link

can't import module #820

Closed KonradowyPL closed 1 year ago

KonradowyPL commented 2 years ago

while importing module this error message shown:

Traceback (most recent call last): File "...\Python\Python310\lib\site-packages\pptx\compat__init__.py", line 10, in 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 "...\main.py", line 1, in File "...\Python\Python310\lib\site-packages\pptx__init.py", line 14, in from pptx.api import Presentation # noqa File "...\Python\Python310\lib\site-packages\pptx\api.py", line 15, in File "...\Python\Python310\lib\site-packages\pptx\package.py", line 6, in from pptx.opc.package import OpcPackage File "...\Python\Python310\lib\site-packages\pptx\opc\package.py", line 11, in File "...\Python\Python310\lib\site-packages\pptx\compat\init__.py", line 14, in Container = collections.Container AttributeError: module 'collections' has no attribute 'Container'

SoloJoeKing commented 2 years ago

I was able to get it to work by adding - 'import collections.abc' in init.py file.
[File "...\Python\Python310\lib\site-packages\pptxinit.py", line 14] -

AJHutchenreuther commented 2 years ago

SoloJoeKing _

_I was able to get it to work by adding - 'import collections.abc' in init.py file. [File "...\Python\Python310\lib\site-packages\pptxinit.py", line 14]__

  • Thank you. Same error message for your comment gave me enough information to make it work. I edited at this location: [File "...\AppData\Local\Programs\Python\Python310\Lib\site-packages\pptx\compat__init__.py"] I added: import collections.abc immediately below import collections. Particulars: Novice in Visual Studio Code in Windows 11, Python 3.10.
SoloJoeKing commented 2 years ago

I struggled for about an hour - reading through the error messages and walking back module references. Glad it worked for you. That's about all the help I'll be able to offer!

kascodeo commented 1 year ago

This issue is fixed. python-pptx-fix

scanny commented 1 year ago

Fixed in release 0.6.22 circa Aug 28, 2023.