EbookLib
Ebook library which can handle EPUB2/EPUB3 format
What it is and what it does
EbookLib is a Python library for reading and writing EPUB2 and EPUB3 e-book files. It provides a straightforward API to parse EPUB archives, extract content (text, images, metadata), and programmatically construct new e-books from scratch. The library handles the underlying XML structure and ZIP packaging that EPUB files use, exposing a higher-level interface for chapters, metadata, covers, tables of contents, and styling.
The package depends on lxml for XML processing and six for Python 2/3 compatibility (though version 0.20 is the final release supporting Python 2.7). It is actively maintained, supports modern Python versions (3.9–3.13), and is used in production by several open-source projects including Booktype, Marker, and Telemeta. The API is designed to handle both simple operations and complex e-book structures.
Use it for:
- Extract all images and text from an existing EPUB file for processing or conversion to another format.
- Programmatically generate EPUB e-books from structured data (e.g., converting Markdown or HTML content into a publishable e-book).
- Modify e-book metadata, add chapters, or rebuild the table of contents in an existing EPUB file.
- Build e-book generation pipelines that produce EPUB output as part of a larger publishing workflow.
- Parse and validate EPUB file structure for quality assurance or compliance checking.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
EbookLib reads and writes EPUB2/EPUB3 files programmatically, allowing you to extract, modify, and create e-book content with support for metadata, covers, tables of contents, and multimedia.
Yes. EbookLib is a mature, actively maintained library with low install friction, no known vulnerabilities, and a clear use case for anyone working with EPUB files programmatically. The AGPL license is a significant consideration for proprietary projects, but poses no barrier for open-source work. Install it if you need to read, write, or manipulate EPUB files in Python.
Install
ebooklib on PyPI
pip
pip install ebooklibuv
uv add ebooklibpoetry
poetry add ebooklibInstalling EbookLib
Before you install
Low install friction with only two runtime dependencies (lxml and six). The project is actively maintained with a recent commit on 2026-07-27 and 1802 repository stars. Version 0.20 is marked as the final release supporting Python 2.7; future versions will drop legacy support.
License in practice
Licensed under AGPL, which requires that any modifications or derivative works using this library must also be released under AGPL. This is a copyleft license with stronger obligations than permissive licenses—suitable for open-source projects but may conflict with proprietary software licensing strategies.
Quickstart
from ebooklib import epub
# Read an EPUB file
book = epub.read_epub('test.epub')
for image in book.get_items_of_type(ebooklib.ITEM_IMAGE):
print(image.get_name())
# Write an EPUB file
book = epub.EpubBook()
book.set_title('My Book')
epub.write_epub('output.epub', book)
Verify before relying
- Whether the library handles all EPUB3 optional features (e.g., fixed layouts, media overlays, embedded fonts).
- Performance characteristics when processing large EPUB files or batch operations.
- Compatibility with non-standard or corrupted EPUB files in the wild.
Package facts
| License | GNU Affero General Public License (agpl) |
| Python support | supports the current Python release (>=2.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — lxml, six |
| Maintenance | actively maintained — 292 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,309,072/month — #4,077 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ebooklib-0.20-py3-none-any.whl
Keywords: ebook, epub
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
jupyter-bookJupyter Book converts Markdown files and…
permissive · top 15,000 on PyPI
borbborb reads, writes, and manipulates PDF files…
agpl · top 15,000 on PyPI
pyexcelProvides a single API to read, write, and…
permissive · top 5,000 on PyPI
aspose-wordsAspose.Words for Python is a document…
unclear · top 15,000 on PyPI
doclingDocling parses diverse document formats—PDF,…
permissive · top 5,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
pyandocPyandoc wraps Pandoc to convert between…
permissive · top 5,000 on PyPI
arParses and reads ar archive files (.a),…
permissive · top 15,000 on PyPI
docxCreates, reads, and writes Microsoft Office…
unclear · top 15,000 on PyPI
kvfReads and writes configuration files in KvF…
permissive · top 15,000 on PyPI