python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

Cannot read POTX files

Open 9021007 opened this issue 6 months ago • 1 comments

Hello! I am unable to parse POTX files.

Repro steps:

  1. Create a presentation.
  2. Save it as example.potx
  3. Create the following python script
from pptx import Presentation

with open('example.potx', 'rb') as f:
    prs = Presentation(f)
  1. Run the python script
  2. Observe the following error:
Traceback (most recent call last):
  File "filepath/script.py", line 4, in <module>
    prs = Presentation(f)
          ^^^^^^^^^^^^^^^
  File "parent_dir_here/venv/lib/python3.12/site-packages/pptx/api.py", line 35, in Presentation
    raise ValueError(tmpl % (pptx, presentation_part.content_type))
ValueError: file '<_io.BufferedReader name='example.potx'>' is not a PowerPoint file, content type is 'application/vnd.openxmlformats-officedocument.presentationml.template.main+xml'

I am using python-pptx v1.0.2, on W11 WSL Ubuntu 24.04.02 LTS, Python 3.12.3, Pip 24.0, and MS365 PowerPoint v2505, Build 18827.20164

9021007 avatar Jun 23 '25 23:06 9021007