python-pptx is a Python library for creating, reading, and updating PowerPoint (.pptx) files. A typical use would be generating a PowerPoint presentation from dynamic content such as a database query, analytics output, or a JSON payload. It is currently at version 1.0.2 and aims for industrial-grade reliability with a comprehensive testing regimen.
pip install python-pptxVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to create a new PowerPoint presentation, add a title slide with text, and then add a blank slide with a custom textbox.
Consult the release notes and official documentation for specific migration paths. Update code to use new enumeration paths and property names. Handle `\v` for line breaks when parsing or generating text.
Ensure all input files are in the `.pptx` format. Convert older `.ppt` files using Microsoft PowerPoint if necessary.
Implement explicit checks or user confirmation mechanisms in your application before saving to an existing file path, or ensure unique filenames are generated.
Always use `prs = Presentation()` or `prs = Presentation('path/to/file.pptx')`.If charting features are used and issues arise, explicitly install `XlsxWriter`: `pip install XlsxWriter`.
Use `import pptx` or `from pptx import Presentation` to import the library.
Access the `add_slide` method through the `slides` collection: `slide_layout = prs.slide_layouts[0] slide = prs.slides.add_slide(slide_layout)`
Use a valid `builtin_chart_type` enum member from `pptx.enum.chart`, for example: `XL_CHART_TYPE.COLUMN_CLUSTERED`.
Ensure the file exists and the path (absolute or relative) is correct, for example: `prs = Presentation('path/to/your/template.pptx')`.