Fix Comptype module needed to save PNGs When Converting PPT to PNG

By | April 10, 2024

When we are using python_pptx_interface to convert a pptx to png images, we may get this error: Comptype module needed to save PNGs.

In this tutorial, we will introduce how to fix.

Here is the example code:

presentation_path = r"1015.pptx"
from pptx_tools import utils  # needs python-pptx-interface installed
# you should use full paths, to make sure PowerPoint can handle the paths
png_folder = "./images"

utils.save_pptx_as_png(png_folder, presentation_path, overwrite_folder=True)

Run this code, we will get this error.

How to fix?

It is easy to fix, we should install comtypes package.

pip install -i comtypes  --trusted-host

Then, we can find this error is fixed.