Last modified: Aug 23, 2026

Create PPT with Python: Easy Guide

Creating PowerPoint presentations manually can be slow. You repeat the same steps for every slide. Python offers a smart solution. You can automate slide creation with a few lines of code. This guide shows you how.

We will use the python-pptx library. It is simple and powerful. You can build slides, add text, and insert images. This saves you hours of work. Let's start from the basics.

Install the Required Library

First, you need to install python-pptx. Open your terminal or command prompt. Run the pip command below. It will download and install the library for you.


pip install python-pptx

That's it. You are ready to create your first presentation. The library works on Windows, Mac, and Linux. It doesn't require PowerPoint to be installed.

Create a Simple Presentation

Let's write a basic script. We will create a presentation with one slide. The slide will have a title and a subtitle. This is the foundation for everything else.


# Import the Presentation class
from pptx import Presentation

# Create a new presentation object
prs = Presentation()

# Use the first slide layout (Title Slide)
slide_layout = prs.slide_layouts[0]

# Add a slide with this layout
slide = prs.slides.add_slide(slide_layout)

# Access the title and subtitle placeholders
title = slide.shapes.title
subtitle = slide.placeholders[1]

# Set the text content
title.text = "Hello, Python!"
subtitle.text = "Automating PowerPoint with code."

# Save the presentation
prs.save("my_first_ppt.pptx")
print("Presentation created successfully!")

Run this script. You will see a file named my_first_ppt.pptx in your folder. Open it. You have a clean title slide. This is just the beginning.

Add More Slides with Different Layouts

One slide is not enough. You usually need multiple slides. The library provides many built-in layouts. You can choose from title, content, and blank layouts. Let's add a slide with a title and content area.


# Continue from previous code
# Select the 'Title and Content' layout (index 1)
content_layout = prs.slide_layouts[1]

# Add a new slide
slide2 = prs.slides.add_slide(content_layout)

# Set the title
slide2.shapes.title.text = "Why Use Python?"

# Access the content placeholder
content_placeholder = slide2.placeholders[1]

# Add text to the content area
text_frame = content_placeholder.text_frame
text_frame.text = "Here is a simple list:"
p = text_frame.add_paragraph()
p.text = "Saves time"
p.level = 1  # Indent level
p = text_frame.add_paragraph()
p.text = "Reduces errors"
p.level = 1

# Save again
prs.save("my_first_ppt.pptx")

Now you have two slides. The second slide has a bulleted list. You can add as many paragraphs as you need. This is great for meeting agendas or project updates.

Add Pictures to Your Slides

Visuals make presentations better. You can easily insert images. Use the add_picture() method. You need to provide the image file path and position. For more detailed options, check this Python PPTX Add Picture Guide for advanced positioning and sizing tips.


# Add a new blank slide (layout index 6 usually blank)
blank_layout = prs.slide_layouts[6]
slide3 = prs.slides.add_slide(blank_layout)

# Add a picture from a file
# Make sure you have an image named 'chart.png' in your folder
from pptx.util import Inches

# Position and size in inches
left = Inches(1)
top = Inches(1)
width = Inches(5)
height = Inches(4)

# Add the picture
pic = slide3.shapes.add_picture('chart.png', left, top, width, height)

# Save the file
prs.save("my_first_ppt.pptx")
print("Picture added to slide 3.")

Replace 'chart.png' with your actual image file. The picture will appear on the slide. You can control its exact size and position. This is perfect for adding logos, screenshots, or data charts.

Use Templates for Professional Design

Starting from a blank template is okay. But using a pre-designed template looks better. You can load an existing PowerPoint file as your base. This way, you keep the branding and fonts. Learn how to leverage existing designs in this Python PPTX: Use Template for Easy Slides article.


# Load an existing presentation as a template
prs = Presentation('my_template.pptx')

# Now add new slides on top of the template's design
slide_layout = prs.slide_layouts[1]  # Use a layout from the template
slide = prs.slides.add_slide(slide_layout)
slide.shapes.title.text = "New Slide with Template Design"

# Save as a new file
prs.save("presentation_with_template.pptx")

Templates save you from formatting every text box. They also ensure consistency. Your slides will look professional without extra effort.

Add Charts and Tables

Data is easier to understand with charts. The library supports adding charts directly. You can create bar charts, line charts, and pie charts. Here is a simple example for a bar chart.


# Import chart classes
from pptx.chart.data import CategoryChartData
from pptx.enum.chart import XL_CHART_TYPE

# Add a new slide with content layout
slide4 = prs.slides.add_slide(prs.slide_layouts[5])  # Chart layout

# Define chart data
chart_data = CategoryChartData()
chart_data.categories = ['Q1', 'Q2', 'Q3', 'Q4']
chart_data.add_series('Sales', (250, 300, 275, 400))

# Add chart to slide
chart = slide4.shapes.add_chart(
    XL_CHART_TYPE.COLUMN_CLUSTERED,  # Type of chart
    Inches(1), Inches(1),  # Position
    Inches(6), Inches(4),  # Size
    chart_data
)

prs.save("my_first_ppt.pptx")
print("Chart added.")

Tables are also easy. You can create a table and fill it with data. This is useful for comparisons or schedules. The process is similar to adding a shape.

Conclusion

Creating PPT with Python is straightforward. You can generate slides, add text, images, charts, and even use templates. This automation is perfect for reports, dashboards, and bulk presentations. You save time and avoid manual errors.

Start with simple scripts. Then add more features as you learn. The python-pptx library is well-documented. You can handle complex tasks with a bit of practice. Try combining it with data from Excel or databases for dynamic reports.

Now you have the tools to create professional presentations quickly. Open your editor and start coding. Your future self will thank you for automating this boring task.