python-pptx 1.0.2
pip install python-pptx Copy PIP instructions
Released: Aug 7, 2024
Create, read, and update PowerPoint 2007+ (.pptx) files.
Verified details (What is this?)
Maintainers.
Unverified details
Project links.
- Documentation
- License: MIT License (MIT)
- Author: Steve Canny
- Tags powerpoint, ppt, pptx, openxml, office
- Requires: Python >=3.8
Classifiers
- 5 - Production/Stable
- OSI Approved :: MIT License
- OS Independent
- Python :: 3
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Office/Business :: Office Suites
- Software Development :: Libraries
Project description
python-pptx is a Python library for creating, reading, and updating PowerPoint (.pptx) files.
A typical use would be generating a PowerPoint presentation from dynamic content such as a database query, analytics output, or a JSON payload, perhaps in response to an HTTP request and downloading the generated PPTX file in response. It runs on any Python capable platform, including macOS and Linux, and does not require the PowerPoint application to be installed or licensed.
It can also be used to analyze PowerPoint files from a corpus, perhaps to extract search indexing text and images.
In can also be used to simply automate the production of a slide or two that would be tedious to get right by hand, which is how this all got started.
More information is available in the python-pptx documentation .
Browse examples with screenshots to get a quick idea what you can do with python-pptx.
Project details
Release history release notifications | rss feed.
Aug 7, 2024
Aug 5, 2024
Aug 3, 2024
Nov 2, 2023
Aug 29, 2023
Sep 20, 2021
Sep 14, 2021
May 17, 2021
May 3, 2019
Dec 16, 2018
Nov 10, 2018
Sep 24, 2018
Sep 10, 2018
Aug 12, 2018
Jul 25, 2018
Jun 11, 2018
May 9, 2018
Apr 18, 2018
Oct 30, 2017
Jun 18, 2017
Mar 22, 2017
Mar 17, 2017
Feb 28, 2017
Jan 3, 2017
Oct 9, 2016
Aug 18, 2016
Nov 28, 2015
Jan 18, 2015
Dec 7, 2014
Nov 18, 2014
Nov 16, 2014
Nov 10, 2014
Oct 27, 2014
Sep 22, 2014
Sep 14, 2014
Apr 30, 2014
Feb 7, 2014
Jan 10, 2014
Dec 13, 2013
0.3.0rc1 pre-release
Jun 22, 2013
Jun 12, 2013
May 17, 2013
May 6, 2013
Mar 26, 2013
Feb 25, 2013
Feb 11, 2013
0.1.0a1 pre-release
Jan 26, 2013
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages .
Source Distribution
Uploaded Aug 7, 2024 Source
Built Distribution
Uploaded Aug 7, 2024 Python 3
Hashes for python_pptx-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ||
MD5 | ||
BLAKE2b-256 |
Hashes for python_pptx-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ||
MD5 | ||
BLAKE2b-256 |
- português (Brasil)
Supported by
Fix "ModuleNotFoundError: No module named 'python-pptx'" error
Package description, related links.
- python-pptx 0.6.21.1 documentation »
- Presentations
Presentations ¶
A presentation is opened using the Presentation() function, provided directly by the pptx package:
This function returns a Presentation object which is the root of a graph containing the components that constitute a presentation, e.g. slides, shapes, etc. All existing presentation components are referenced by traversing the graph and new objects are added to the graph by calling a method on that object’s container. Consequently, python-pptx objects are generally not constructed directly.
Presentation function ¶
This function is the only reference that must be imported to work with presentation files. Typical use interacts with many other classes, but there is no need to construct them as they are accessed using a property or method of their containing object.
Return a Presentation object loaded from pptx , where pptx can be either a path to a .pptx file (a string) or a file-like object. If pptx is missing or None , the built-in default presentation “template” is loaded.
Presentation objects ¶
PresentationML (PML) presentation.
Not intended to be constructed directly. Use pptx.Presentation() to open or create a presentation.
Instance of CoreProperties holding the read/write Dublin Core document properties for this presentation.
Instance of NotesMaster for this presentation. If the presentation does not have a notes master, one is created from a default template and returned. The same single instance is returned on each call.
Save this presentation to file , where file can be either a path to a file (a string) or a file-like object.
Height of slides in this presentation, in English Metric Units (EMU). Returns None if no slide width is defined. Read/write.
Sequence of SlideLayout instances belonging to the first SlideMaster of this presentation. A presentation can have more than one slide master and each master will have its own set of layouts. This property is a convenience for the common case where the presentation has only a single slide master.
First SlideMaster object belonging to this presentation. Typically, presentations have only a single slide master. This property provides simpler access in that common case.
Sequence of SlideMaster objects belonging to this presentation
Width of slides in this presentation, in English Metric Units (EMU). Returns None if no slide width is defined. Read/write.
Slides object containing the slides in this presentation.
CoreProperties objects ¶
Each Presentation object has a CoreProperties object accessed via its core_properties attribute that provides read/write access to the so-called core properties for the document. The core properties are author, category, comments, content_status, created, identifier, keywords, language, last_modified_by, last_printed, modified, revision, subject, title, and version.
Each property is one of three types, str , datetime.datetime , or int . String properties are limited in length to 255 characters and return an empty string (‘’) if not set. Date properties are assigned and returned as datetime.datetime objects without timezone, i.e. in UTC. Any timezone conversions are the responsibility of the client. Date properties return None if not set.
python-pptx does not automatically set any of the document core properties other than to add a core properties part to a presentation that doesn’t have one (very uncommon). If python-pptx adds a core properties part, it contains default values for the title, last_modified_by, revision, and modified properties. Client code should change properties like revision and last_modified_by explicitly if that behavior is desired.
string – An entity primarily responsible for making the content of the resource.
string – A categorization of the content of this package. Example values might include: Resume, Letter, Financial Forecast, Proposal, or Technical Presentation.
string – An account of the content of the resource.
string – completion status of the document, e.g. ‘draft’
datetime – time of intial creation of the document
string – An unambiguous reference to the resource within a given context, e.g. ISBN.
string – descriptive words or short phrases likely to be used as search terms for this document
string – language the document is written in
string – name or other identifier (such as email address) of person who last modified the document
datetime – time the document was last printed
datetime – time the document was last modified
int – number of this revision, incremented by the PowerPoint® client once each time the document is saved. Note however that the revision number is not automatically incremented by python-pptx .
string – The topic of the content of the resource.
string – The name given to the resource.
string – free-form version string
Table of Contents
- Presentation()
- Presentation.core_properties
- Presentation.notes_master
- Presentation.save()
- Presentation.slide_height
- Presentation.slide_layouts
- Presentation.slide_master
- Presentation.slide_masters
- Presentation.slide_width
- Presentation.slides
- pptx.opc.coreprops.CoreProperties.author
- pptx.opc.coreprops.CoreProperties.category
- pptx.opc.coreprops.CoreProperties.comments
- pptx.opc.coreprops.CoreProperties.content_status
- pptx.opc.coreprops.CoreProperties.created
- pptx.opc.coreprops.CoreProperties.identifier
- pptx.opc.coreprops.CoreProperties.keywords
- pptx.opc.coreprops.CoreProperties.language
- pptx.opc.coreprops.CoreProperties.last_modified_by
- pptx.opc.coreprops.CoreProperties.last_printed
- pptx.opc.coreprops.CoreProperties.modified
- pptx.opc.coreprops.CoreProperties.revision
- pptx.opc.coreprops.CoreProperties.subject
- pptx.opc.coreprops.CoreProperties.title
- pptx.opc.coreprops.CoreProperties.version
Previous topic
Software Updates
Useful Links
- python-pptx @ GitHub
- python-pptx @ PyPI
- Issue Tracker
Quick search
- Python Course
- Python Basics
- Interview Questions
- Python Quiz
- Popular Packages
- Python Projects
- Practice Python
- AI With Python
- Learn Python3
- Python Automation
- Python Web Dev
- DSA with Python
- Python OOPs
- Dictionaries
Creating and updating PowerPoint Presentations in Python using python – pptx
python-pptx is library used to create/edit a PowerPoint (.pptx) files. This won’t work on MS office 2003 and previous versions. We can add shapes, paragraphs, texts and slides and much more thing using this library.
Installation: Open the command prompt on your system and write given below command:
Let’s see some of its usage:
Example 1: Creating new PowerPoint file with title and subtitle slide.
Example 2: Adding Text-Box in PowerPoint.
Example 3: PowerPoint (.pptx) file to Text (.txt) file conversion.
Example 4: Inserting image into the PowerPoint file.
Example 5: Adding Charts to the PowerPoint file.
Example 6: Adding tables to the PowerPoint file.
Please Login to comment...
Similar reads.
- python-modules
- python-utility
- Top 10 Fun ESL Games and Activities for Teaching Kids English Abroad in 2024
- Top Free Voice Changers for Multiplayer Games and Chat in 2024
- Best Monitors for MacBook Pro and MacBook Air in 2024
- 10 Best Laptop Brands in 2024
- 15 Most Important Aptitude Topics For Placements [2024]
Improve your Coding Skills with Practice
What kind of Experience do you want to share?
ModuleNotFoundError: No module named python-pptx
This error occurs because you are trying to import module python-pptx , but it is not installed in your python environment.
To install the module, execute the following command in termanal:
To install the module inside Google Colab, Kaggle/Jupyter Notebook or ipython environment, execute the following code line/cell:
How it works:
pip - is a standard packet manager in python. This program can install missing module in your local development environment or current Google Colab/Kaggle/Jupyter Notebook session.
! - exclamation mark instructs interactive environment to interpret line/cell content as shell command, not as python code. This is needed because pip command should be executed in shell.
You have already made 2 right things: practicing python and googling error output . Those 2 kinds of actions define a developer. Repeat them long enough, and success is inevitable. Consider subscribing to our DEV blog - it definitely will help to learn python coding and best practices
Get the Reddit app
Subreddit for posting questions and asking for general advice about your python code.
Why can't I use pip to install python-pptx?
Hi, I'm currently doing a project in Jupyter Notebook, which involves extracting the contents of PowerPoint slides to txt format. I tried to install python-pptx using the code
>!pip install python-pptx
but this message showed up.
Defaulting to user installation because normal site-packages is not writeable.
And the Jupyter Notebook showed several messages such as it retrying several times before showing the message below:
ERROR: Could not find a version that satisfies the requirement python-pptx (from versions: none) ERROR: No matching distribution found for python-pptx
Can anyone enlighten me on why this happened? I have been stuck on this problem for quite long... Any help is appreciated!
By continuing, you agree to our User Agreement and acknowledge that you understand the Privacy Policy .
Enter the 6-digit code from your authenticator app
You’ve set up two-factor authentication for this account.
Enter a 6-digit backup code
Create your username and password.
Reddit is anonymous, so your username is what you’ll go by here. Choose wisely—because once you get a name, you can’t change it.
Reset your password
Enter your email address or username and we’ll send you a link to reset your password
Check your inbox
An email with a link to reset your password was sent to the email address associated with your account
Choose a Reddit account to continue
Navigation Menu
Search code, repositories, users, issues, pull requests..., provide feedback.
We read every piece of feedback, and take your input very seriously.
Saved searches
Use saved searches to filter your results more quickly.
To see all available qualifiers, see our documentation .
- Notifications You must be signed in to change notification settings
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open existing pptx file #173
sobolewska commented Aug 12, 2015
python-pptx 0.5.7 Currently using gives error: File is not a zip file using gives error: Package not found at 'C:\some_folder\my_file.pptx' full stack traces below: |
The text was updated successfully, but these errors were encountered: |
- 👍 1 reaction
mfellows commented Aug 12, 2015
For the first method, using a file-like object, you need to open the file in binary mode: = open(r"C:\some_folder\my_file.pptx", "rb") prs = Presentation(f)Not sure why the second one (using the file path) failed though - double-check that the file exists? |
- 🚀 1 reaction
Sorry, something went wrong.
sobolewska commented Aug 13, 2015
gives error when the presentation is EMPTY, there are 0 slides. |
also for the record, in meantime i also made sure to meet requirements: |
finitecow commented Aug 14, 2017 • edited Loading
the second problem is caused by using a os.walk() and in that loop , you don't change your dir by using os.chdir . I guess |
fakabbir commented Jul 17, 2018
I have the same error and it doesn't resolves via adopting the mentioned solutions. |
scanny commented Jul 17, 2018
also occurs when the target file is the old PPT format, the pre-2007 PowerPoint format. If you open one like that with PowerPoint then save as PPTX it normally fixes it. |
ruiyuanlu commented Aug 18, 2018 • edited Loading
I've met the same issue when loading empty pptx files. |
fakabbir commented Aug 18, 2018
Does scanny's solution helped you out ? |
ruiyuanlu commented Aug 21, 2018 • edited Loading
You mean using file handler rather than file path? I met this issue when I simply created pptx files using: ('test.pptx', 'w').close()and then tried to reopen it using: = Presentation('test.pptx')Under this circumstances, the error is 'Package not found'. I'm wondering is that possible to add specific functions to process empty pptx files? Python 3.6 |
scanny commented Aug 21, 2018
An empty file is not a PPTX file. A PPTX file is a zip archive with a prescribed set of contents. An "empty" PPTX file is simply one that has no slides. It does still however have quite a bit of content, like the slide masters, theme, slide layouts, etc. can only operate on PPTX files. Calling with no parameters causes an internal default template PPTX file to be opened. You can create your own starting template by taking the PPTX file of your choice and deleting all its slides and saving it. You may want to spend some time with the documentation here that explains these concepts: |
ruiyuanlu commented Aug 21, 2018
Got it. Thx for the explanation. |
ghost commented Jun 11, 2020
I still see the issue, pptx.exc.PackageNotFoundError: Package not found at {path}/text.pptx'. |
- 👀 1 reaction
No branches or pull requests
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
- OverflowAI GenAI features for Teams
- OverflowAPI Train & fine-tune LLMs
- Labs The future of collective knowledge sharing
- About the company Visit the blog
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Get early access and see previews of new features.
Does anyone know a fix to "pptx.exc.PackageNotFoundError:" when running an exe file built out of a python script with Presentation() object?
I wrote a python script that collects images and places them one slide at a time in a PowerPoint presentation. This script works fine when it is run using ".py" file. I then built an exe file using this python script. When running that ".exe" file, it always gives me an error at the line where Presentation() object is called. The error is captured in the image below: Error that is encountered when running an exe file that was built using pyinstaller
The python script that I am testing is as simple as follows:
The command I used to build exe file out of this script was:
Please help me if you have any solution to this problem. Thank you!
- python-pptx
- Maybe the exe version can't find the base presentation (shipped with python-pptx). – Martin Packer Commented Jul 10, 2022 at 7:33
- I am not sure how to solve that if it can be solved, could you please help? – Aniket Sedhai Commented Jul 10, 2022 at 13:39
- I just decided to have a default.pptx file next to the exe file and use it as the template. – Aniket Sedhai Commented Jul 10, 2022 at 14:49
- What happens if you pass in explicitly a presentation you already have? The compiled version might well find it. Then you'd know if it was a case of not finding the built-in one. – Martin Packer Commented Jul 11, 2022 at 6:56
- 1 @MartinPacker That is what I ended up doing. The package somehow isn’t able to find/use the built in template pptx file. So, I gave it a new “default.pptx” which the package was able to use. Thanks for your help! – Aniket Sedhai Commented Jul 12, 2022 at 10:54
Know someone who can answer? Share a link to this question via email , Twitter , or Facebook .
Your answer.
Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more
Sign up or log in
Post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .
Browse other questions tagged python exe python-pptx or ask your own question .
- The Overflow Blog
- The hidden cost of speed
- The creator of Jenkins discusses CI/CD and balancing business with open source
- Featured on Meta
- Announcing a change to the data-dump process
- Bringing clarity to status tag usage on meta sites
- What does a new user need in a homepage experience on Stack Overflow?
- Feedback requested: How do you use tag hover descriptions for curating and do...
- Staging Ground Reviewer Motivation
Hot Network Questions
- Is reading sheet music difficult?
- How to run only selected lines of a shell script?
- Could a lawyer agree not to take any further cases against a company?
- What would be a good weapon to use with size changing spell
- What was the typical amount of disk storage for a mainframe installation in the 1980s?
- What's the benefit or drawback of being Small?
- Why is it spelled "dummy" and not "dumby?"
- Wien's displacement law
- Is my magic enough to keep a person without skin alive for a month?
- What is the optimal number of function evaluations?
- When can the cat and mouse meet?
- Star Trek: The Next Generation episode that talks about life and death
- do-release-upgrade from 22.04 LTS to 24.04 LTS still no update available
- Why is LiCl a hypovalent covalent molecule?
- Fusion September 2024: Where are we with respect to "engineering break even"?
- Transform a list of rules into a list of function definitions
- What does 'ex' mean in this context
- Etymology of 制度
- Does a party have to wait 1d4 hours to start a Short Rest if no healing is available and an ally is only stabilized?
- Is the 2024 Ukrainian invasion of the Kursk region the first time since WW2 Russia was invaded?
- Pull up resistor question
- Best approach to make lasagna fill pan
- Are old cardano node versions invalidated
- Conjugate elements in an extension
- python-pptx 1.0.0 documentation »
Exceptions ¶
Exceptions used with python-pptx.
The base exception class is PythonPptxError.
Generic error class.
Raised when a package cannot be found at the specified path.
Raised when a value is encountered in the XML that is not valid according to the schema.
Previous topic
util Module
Useful Links
- python-pptx @ GitHub
- python-pptx @ PyPI
- Issue Tracker
IMAGES
VIDEO
COMMENTS
2. file does not exist. file is no valid pptx (unzip file and check folder and file structure) file is corrupt (opening in MS Office, change, save may fix) no access rights for python. file is locked, e.g. opened by MS Office. if you can't find anything maybe provide a sample pptx which is not working. edited Jan 19, 2022 at 7:52.
The word package isn't referring to a Python package. There is a piece of code which deals with different types of object, and if the object is a string it will treat it as a pathname (which is my case and I think yours). The code refers to the object as a package as a general term for object which may be one of a number of types.
Project description. python-pptx is a Python library for creating, reading, and updating PowerPoint (.pptx) files. A typical use would be generating a PowerPoint presentation from dynamic content such as a database query, analytics output, or a JSON payload, perhaps in response to an HTTP request and downloading the generated PPTX file in ...
Installing — python-pptx 0.6.22 documentation
Fix python-pptx Python errors. Easy to understand Quick Reference guide to fix ModuleNotFound Errors in your Python Programs and Scripts. ... Package Description. python-pptx is a Python library for creating and updating PowerPoint (.pptx) files. A typical use would be generating a customized PowerPointpresentation from a template or updating ...
This creates a new presentation from the built-in default template and saves it unchanged to a file named 'test.pptx'. A couple things to note: The so-called "default template" is actually just a PowerPoint file that doesn't have any slides in it, stored with the installed python-pptx package. It's the same as what you would get if ...
python-pptx¶. Release v1.0.0 (Installation)python-pptx is a Python library for creating, reading, and updating PowerPoint (.pptx) files.. A typical use would be generating a PowerPoint presentation from dynamic content such as a database query, analytics output, or a JSON payload, perhaps in response to an HTTP request and downloading the generated PPTX file in response.
No, it's not ready for 3.11. There is an open issue for that, I believe. I think 3.9.x is the latest supported but I'd love to be proven wrong. (Would help if you mentioned if there was some essential function in 3.10 or 3.x you actually need.)
A presentation is opened using the Presentation() function, provided directly by the pptx package: from pptx import Presentation This function returns a Presentation object which is the root of a graph containing the components that constitute a presentation, e.g. slides, shapes, etc.
python-pptx is library used to create/edit a PowerPoint (.pptx) files. This won't work on MS office 2003 and previous versions. We can add shapes, paragraphs, texts and slides and much more thing using this library. Installation: Open the command prompt on your system and write given below command: pip install python-pptx Let's see some of ...
pip install python-pptx . To install the module inside Google Colab, Kaggle/Jupyter Notebook or ipython environment, execute the following code line/cell:!pip install python-pptx How it works: pip - is a standard packet manager in python. This program can install missing module in your local development environment or current Google Colab ...
from pptx import Presentation prs = Presentation (path_to_presentation) # text_runs will be populated with a list of strings, # one for each text run in presentation text_runs = [] for slide in prs. slides: for shape in slide. shapes: if not shape. has_text_frame: continue for paragraph in shape. text_frame. paragraphs: for run in paragraph ...
The third solution is to use --user argument. It will install the package in your python path and somewhere you have write rights. on a side note, i wouldn't recommend using pip raw like that because you don't explicitly know which python is used and will have access to the module you're installing. Use python3 -m pip (if you want python3 ...
An "empty" PPTX file is simply one that has no slides. It does still however have quite a bit of content, like the slide masters, theme, slide layouts, etc. python-pptx can only operate on PPTX files. Calling Presentation() with no parameters causes an internal default template PPTX file to be opened.
Presentations. ¶. A presentation is opened using the Presentation() function, provided directly by the pptx package: from pptx import Presentation. This function returns a Presentation object which is the root of a graph containing the components that constitute a presentation, e.g. slides, shapes, etc. All existing presentation components are ...
It seems you are trying to find a package called pptx but that package does not exist on any of your registered channels. Share. Improve this answer. Follow answered Aug 22, 2018 at 3:51. Adam Chubbuck Adam ... Resolving Python-pptx package not found. Hot Network Questions
The Slides object is accessed using the slides property of Presentation. It is not intended to be constructed directly. class pptx.slide.Slides[source] ¶. Sequence of slides belonging to an instance of Presentation. Has list semantics for access to individual slides. Supports indexed access, len (), and iteration.
I wrote a python script that collects images and places them one slide at a time in a PowerPoint presentation. This script works fine when it is run using ".py" file. ... Maybe the exe version can't find the base presentation (shipped with python-pptx). - Martin Packer. Commented Jul 10, ... PPTX Package not Found.
Exceptions¶. Exceptions used with python-pptx. The base exception class is PythonPptxError. exception pptx.exc.PythonPptxError [source] ¶. Generic error class ...