pptx-debug-workflow
यह क्या करती है
यह स्किल python-pptx लाइब्रेरी से .pptx प्रेज़ेंटेशन बनाने का सावधानी वाला तरीका है, जिसमें हर चरण पर परीक्षण और डीबगिंग होती है। यह उन लोगों के लिए है जो डेक बनाने वाला कोड लिखते हैं और कम गलतियाँ चाहते हैं।
कब इस्तेमाल करें
- ✓जब मैं Python कोड लिख रहा हूँ जो PowerPoint प्रेज़ेंटेशन बनाता है।
- ✓जब डेक स्क्रिप्ट विफल हो और मुझे कारण ढूँढना हो।
- ✓जब पूरी प्रेज़ेंटेशन बनाने से पहले पक्का करना हो कि python-pptx काम करता है।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pptx-debug-workflow/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे लिए एक Python स्क्रिप्ट लिखने में मदद कीजिए जो चार्ट और कई स्लाइड वाली PowerPoint बनाए। पहले बुनियादी बातें टेस्ट कीजिए, ताकि गलतियाँ कम हों।”
हर हफ़्ते 5 नई skills, 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:
- Verify the
.pptxfile was created - Open in PowerPoint or compatible viewer
- 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
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
feishu-doc
394kयह आपके एजेंट को document टूल से Feishu क्लाउड दस्तावेज़ पढ़ने, बनाने और बदलने में मदद करती है, जिसमें टेक्स्ट, इमेज और टेबल शामिल हैं।
feishu-drive
394kयह आपके एजेंट को बॉट के साथ साझा किए गए Feishu क्लाउड फ़ोल्डर में फ़ाइलें देखने, व्यवस्थित करने और उन पर टिप्पणी करने देती है।
feishu-perm
394kयह आपके एजेंट को Feishu फ़ाइल तक किसकी पहुंच है, यह जांचने और बदलने देती है, और आपके अनुरोध के लिए सबसे छोटी अनुमति चुनती है।