Aspose Slides for Python via .NET

raw JSON →
26.4.0 verified Mon Apr 27 auth: no python

Aspose.Slides for Python via .NET is a class library that enables applications to read, write, manipulate, and convert PowerPoint presentations (PPT, PPTX, PPS, POT, PPSX, etc.) without requiring Microsoft PowerPoint. Version 26.4.0 supports Python 3.5 to 3.13. Releases occur monthly.

pip install aspose-slides
error ModuleNotFoundError: No module named 'aspose'
cause aspose-slides not installed or installed in wrong environment.
fix
pip install aspose-slides. Ensure you are using the correct Python interpreter/venv.
error AttributeError: module 'aspose.slides' has no attribute 'Presentation'
cause Wrong import pattern. Direct import from aspose.slides does not export Presentation.
fix
Use 'import aspose.slides as slides' then 'slides.Presentation()'.
error NotImplementedError: The method or operation is not implemented.
cause Some features from .NET are not yet available via Python wrapper. For example, certain chart types or complex formatting.
fix
Check the Aspose.Slides for Python documentation for supported features. Consider using the .NET API directly via pythonnet if needed.
error System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
cause Modifying shapes collection while iterating over it without using index-based loops.
fix
Use for i in range(len(slide.shapes)): and access via index, or collect items in a list first.
gotcha The Presentation class must be disposed to release .NET resources. Use a context manager or call dispose() explicitly to avoid memory leaks.
fix with slides.Presentation() as pres: ... or pres = slides.Presentation(); ...; pres.dispose()
gotcha Importing aspose.slides takes a few seconds because it loads .NET runtime. Do not import in hot loops.
fix Perform import once at module level, not inside functions/loops.
breaking In version 24.x, the aspose.slides namespace was restructured. Some classes moved to submodules (e.g., SaveFormat moved to aspose.slides.export).
fix Update imports: from aspose.slides.export import SaveFormat instead of from aspose.slides import SaveFormat.
gotcha The Slice class was renamed to Slide in older versions. Always use slides.Slide for slide objects.
fix Use pres.slides[0] to access slides; iterate with for slide in pres.slides:
deprecated Methods like add_rectangle() and add_ellipse() are deprecated. Use add_auto_shape() with ShapeType instead.
fix shape = slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, left, top, width, height)

Creates a simple presentation with one slide, adds a rectangle with text, and saves as PPTX.

import aspose.slides as slides

# Create a presentation
pres = slides.Presentation()

# Add a slide and a shape
slide = pres.slides[0]
shape = slide.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 50, 50, 200, 100)

# Add text
shape.text_frame.text = 'Hello, Aspose.Slides!'

# Save
pres.save('output.pptx', slides.export.SaveFormat.PPTX)
print('Presentation saved.')