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)
- 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)
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 https://mirrors.aliyun.com/pypi/simple/ comtypes --trusted-host mirrors.aliyun.com
- pip install -i https://mirrors.aliyun.com/pypi/simple/ comtypes --trusted-host mirrors.aliyun.com
pip install -i https://mirrors.aliyun.com/pypi/simple/ comtypes --trusted-host mirrors.aliyun.com
Then, we can find this error is fixed.