python-pptx with oxml access
raw JSON → 1.0.3 verified Sat May 09 auth: no python
A fork of python-pptx (v1.0.3) that exposes the oxml internal module for direct XML manipulation while keeping the same high-level API. Provides create, read, and update support for PowerPoint 2007+ (.pptx) files. Requires Python >=3.8.
pip install pypptx-with-oxml Common errors
error ImportError: cannot import name 'element' from 'pptx.oxml' ↓
cause oxml is not a package in this fork; it's a module attribute.
fix
Replace 'from pptx.oxml import element' with 'from pptx import oxml' then use oxml.element.
error AttributeError: module 'pptx' has no attribute 'oxml' ↓
cause Attempted to access oxml before importing pptx or using old import pattern.
fix
Ensure you have installed pypptx-with-oxml (not python-pptx) and use 'from pptx import oxml' after importing pptx.
Warnings
breaking oxml is not a submodule; you must access it via 'from pptx import oxml' after importing pptx, not 'from pptx.oxml import ...'. ↓
fix Use 'from pptx import oxml' and then access e.g. oxml.parse_xml().
gotcha This fork may lag behind upstream python-pptx; check for feature parity. ↓
fix Review upstream changelog before relying on new python-pptx features.
deprecated Direct manipulation of oxml bypasses high-level validation; corrupt presentations are possible. ↓
fix Prefer high-level API methods; use oxml only when necessary and validate output.
Imports
- Presentation
from pptx import Presentation - oxml wrong
from pptx.oxml import something # raises ImportErrorcorrectfrom pptx import oxml
Quickstart
from pptx import Presentation
from pptx.util import Inches, Pt
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[6]) # blank
slide.shapes.title.text = 'Hello, World!'
prs.save('test.pptx')