Skip to content
cccskills
FreePublished on GitHub

pptx-debug-workflow

Debug PowerPoint generation with python-pptx, a Python library for presentations. Follow a sequence of installation checks, minimal tests, error logging, and fixes for tables and charts, then inspect the generated slides.

OriginalShow the original description

Systematic debugging workflow for python-pptx presentation generation

Works withPowerPoint
See how to install

Good for

  • Diagnosing errors in PowerPoint generation
  • Fixing table and chart code
  • Saving detailed error logs
  • Checking generated presentation files

Files included (2)

  • SKILL.md4.4 KB
  • .skill_id33 B

SKILL.md (original)

Review the instructions the agent will receive before you install.

PPTX Debugging Workflow

A systematic approach to creating and debugging PowerPoint presentations using the python-pptx library. This workflow ensures reliable presentation generation through iterative verification and error resolution.

Step 1: Verify Installation

Before writing any code, verify that python-pptx is installed:

pip show python-pptx

If not installed:

pip install python-pptx

Step 2: Test Minimal PPTX Creation

Create and run a minimal test script to verify the library works:

from pptx import Presentation

prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[0])
slide.shapes.title.text = "Test Slide"
prs.save("test.pptx")
print("Test presentation created successfully")

Run this first to confirm basic functionality before building complex presentations.

Step 3: Write Full Script to File

Always write your presentation script to a .py file instead of using heredoc or inline execution. This enables:

  • Better error messages with line numbers
  • Easier iteration and debugging
  • Preserved state between error fixes

Example structure:

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.shapes import MSO_SHAPE
from pptx.enum.chart import XL_CHART_TYPE, XL_LEGEND_POSITION
from pptx.chart.data import CategoryChartData

def create_presentation():
    prs = Presentation()
    # Build slides here
    prs.save("output.pptx")
    print("Presentation saved successfully")

if __name__ == "__main__":
    create_presentation()

Step 4: Execute and Capture Full Traceback

Run the script with full error output:

python your_script.py 2>&1 | tee debug_output.log

This captures the complete Python traceback including:

  • Error type and message
  • Line numbers where errors occurred
  • Stack trace for debugging

Step 5: Fix API Errors Iteratively

Common python-pptx API patterns to remember:

Chart Legend Positioning

Use XL_LEGEND_POSITION (NOT XL_CHART_TYPE) for legend positioning:

from pptx.enum.chart import XL_LEGEND_POSITION

chart.chart.has_legend = True
chart.chart.legend.position = XL_LEGEND_POSITION.RIGHT

Table Cell Access

Access table cells through row iteration pattern:

table = slide.shapes.add_table(rows=5, cols=4, left=Inches(1), top=Inches(2), width=Inches(6), height=Inches(3)).table

# Correct pattern - iterate through rows, then cells
for row_idx, row in enumerate(table.rows):
    for cell_idx, cell in enumerate(row.cells):
        cell.text = f"Row {row_idx}, Cell {cell_idx}"

# Or direct access
table.rows[0].cells[0].text = "Header"

Chart Data Format

For pie charts, use category-based data:

chart_data = CategoryChartData()
chart_data.categories = ['Category A', 'Category B', 'Category C']
chart_data.add_series('Series 1', (30, 45, 25))

x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
slide.shapes.add_chart(XL_CHART_TYPE.PIE, x, y, cx, cy, chart_data)

Step 6: Validate Output

After successful execution:

  1. Verify the .pptx file was created
  2. Open in PowerPoint or compatible viewer
  3. Check that all slides, tables, and charts render correctly

Common Troubleshooting

IssueSolution
Module not foundpip install python-pptx
AttributeError on chartCheck XL_LEGEND_POSITION vs XL_CHART_TYPE
Table cell access failsUse table.rows[row].cells[cell] pattern
Chart doesn't displayVerify chart_data format matches chart type
Import errorsCheck enum imports from pptx.enum.*

Quick Reference Script Template

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.chart import XL_CHART_TYPE, XL_LEGEND_POSITION
from pptx.chart.data import CategoryChartData

def main():
    prs = Presentation()
    
    # Add title slide
    slide = prs.slides.add_slide(prs.slide_layouts[0])
    slide.shapes.title.text = "Title"
    
    # Add content slide with table
    slide = prs.slides.add_slide(prs.slide_layouts[1])
    table = slide.shapes.add_table(3, 3, Inches(1), Inches(2), Inches(8), Inches(2)).table
    for row in table.rows:
        for cell in row.cells:
            cell.text = "Data"
    
    prs.save("presentation.pptx")
    print("Done!")

if __name__ == "__main__":
    main()

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Prepare audio stems, the separate parts of a track, for mixing by matching their durations with silence, loops, or crossfades. Verify each generated and processed file before moving to the next production step.

  • Match audio parts with different durations
  • Extend drums and melodic parts using suitable methods
  • Check audio specifications before mixing
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Produce audio in separate stems, meaning individual instrument tracks, and verify each output as you go. Align track lengths with silence, loops, or crossfades, then apply effects, mix a master, and package the files.

  • Align instrument tracks to a reference audio file
  • Choose how to extend tracks that are too short
  • Verify audio properties after generation and effects
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Produce a master track and separate audio parts through a structured Python workflow. Apply filters and reverb, export WAV files with consistent settings, package them in a ZIP archive, and check that the deliverables meet the requested specifications.

  • Export a master track with separate audio parts
  • Apply filters and reverb to audio
  • Check duration and format across deliverables
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

When Python execution repeatedly fails in execute_code_sandbox, use a file-based alternative: save the script, run it through the shell, and capture results or errors. The guidance covers paths, imports, timeouts, structured output, and optional cleanup.

  • Retry Python work through the shell after repeated sandbox failures
  • Run longer tasks with an adjusted timeout
  • Execute Python work that needs multiple files or system utilities
HKUDS/OpenSpace7.8KUpdated Aug 13, 2026

See all skills by HKUDS

Report a problem with this skill