--- id: ebooklib version: "0.20" license: GNU Affero General Public License license_treatment: agpl maintenance: active --- # EbookLib — Ebook library which can handle EPUB2/EPUB3 format License: agpl · Maintenance: active · Downloads: 1.3M/mo ## 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 above — 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 pip install ebooklib uv add ebooklib poetry add ebooklib ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 1.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags read write epub files python, epub parser library, ebook format handling, epub2 epub3 support, programmatic ebook creation, extract epub content, ebook metadata management, epub-handling, ebook-generation [View on SkillFed](https://skillfed.io/packages/ebooklib) · [View on PyPI](https://pypi.org/project/ebooklib/)