본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12947

pptx-debug-workflow

하는 일

이 스킬은 각 단계에서 테스트와 디버깅을 하며 python-pptx 라이브러리로 .pptx 발표 자료를 만드는 신중한 방법입니다. 오류를 줄이려는 덱 제작 코드 작성자에게 맞습니다.

사용하는 경우

  • ✓PowerPoint 발표 자료를 만드는 Python 코드를 쓰고 있을 때.
  • ✓덱 스크립트가 실패해서 원인을 찾아야 할 때.
  • ✓전체 덱을 만들기 전에 python-pptx가 작동하는지 확인하고 싶은 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pptx-debug-workflow/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pptx-debug-workflow/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“차트와 여러 슬라이드가 있는 PowerPoint를 만드는 Python 스크립트를 작성하도록 도와주세요. 오류를 피하도록 기본 기능부터 먼저 테스트해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 python-pptx가 설치되어 있는지 확인하고, 최소 테스트 덱을 실행한 뒤, 전체 스크립트를 파일로 써서 오류가 줄 번호와 함께 보이고 다시 실행할 수 있게 합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

Issue Solution
Module not found pip install python-pptx
AttributeError on chart Check XL_LEGEND_POSITION vs XL_CHART_TYPE
Table cell access fails Use table.rows[row].cells[cell] pattern
Chart doesn't display Verify chart_data format matches chart type
Import errors Check 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()
자주 묻는 질문

최소 덱을 먼저 테스트하는 이유는 무엇인가요?

전체 발표 자료에 시간을 쓰기 전에 라이브러리가 작동하는지 확인하기 때문입니다.

스크립트를 파일로 쓰는 이유는 무엇인가요?

파일은 줄 번호가 있는 더 분명한 오류 메시지를 주고, 편집 후 다시 실행할 수 있습니다.

덱에 차트를 넣을 수 있나요?

네, 예제는 python-pptx에서 차트 종류와 차트 데이터 클래스를 가져옵니다.

상세 정보

작성자의 원본 설명

Systematic debugging workflow for python-pptx presentation generation

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12947
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬