py7zr
Pure python 7-zip library
What it is and what it does
py7zr is a pure-Python implementation of 7z archive handling, providing both a library API and command-line tools for compression, decompression, encryption, and decryption. It wraps Python's standard lzma module and adds support for additional algorithms (Brotli, ZStandard, PPMd) and encryption (7zAES) via third-party libraries. The package works on Linux, macOS, Windows, and ARM platforms.
You use it when you need to work with 7z archives from Python without external system dependencies. It supports password-protected archives, selective file extraction, multi-volume archives, and custom filter chains. The library provides both context-manager-based file operations and a shutil integration layer for archive registration.
Use it for:
- Extract password-protected 7z archives in a Python application without calling external tools
- Create compressed archives with custom algorithms like Brotli or ZStandard for distribution
- Selectively extract files from large archives using regex patterns without full decompression
- Build multi-volume archives for storage or transfer across size-limited media
- Integrate 7z support into backup or data pipeline tools via the shutil interface
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
py7zr is a pure-Python library for reading, writing, and managing 7z archives with support for multiple compression algorithms, encryption, and both programmatic and command-line interfaces.
Yes. py7zr is actively maintained, has no known vulnerabilities, installs with low friction, and offers broad algorithm support. The LGPL-2.1-or-later license is permissive for most use cases as long as you distribute source. Install if you need 7z handling in Python; avoid only if your project cannot accept copyleft licensing.
Install
py7zr on PyPI
pip
pip install py7zruv
uv add py7zrpoetry
poetry add py7zrInstalling py7zr
Before you install
Low friction: pure-Python wheel with no compiled dependencies. Active maintenance with recent releases; last commit 2026-07-17. Requires Python 3.10 or later.
License in practice
LGPL-2.1-or-later (copyleft): you may use and modify freely, but derivative works and distributions must remain under the same license and include source.
Quickstart
import py7zr
with py7zr.SevenZipFile('sample.7z', mode='r') as archive:
archive.extractall(path='/tmp')
# Or compress:
with py7zr.SevenZipFile('target.7z', 'w') as archive:
archive.writeall('/path/to/base_dir', 'base')
Requires Python 3.10 or later; standard lzma module support varies by Python implementation.
Verify before relying
- Exact compatibility with original 7-zip on Windows and p7zip on Linux/macOS for all algorithms
- Performance characteristics compared to system 7z tools for large archives
- Symbolic link handling safety guarantees beyond the documented ValueError checks
Package facts
| License | LGPL-2.1-or-later (copyleft) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 10 — texttable, pycryptodomex, brotli, brotlicffi, psutil, backports.zstd, pyppmd, pybcj, multivolumefile, inflate64 |
| Maintenance | actively maintained — 56 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,610,773/month — #1,519 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: py7zr-1.1.3-py3-none-any.whl
Keywords: compression, 7zip, lzma, zstandard, ppmd, lzma2, bcj, archive
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
pyppmdCompresses and decompresses data using the PPMd…
copyleft · top 5,000 on PyPI
pyunpackUnpacks archive files in Python with support…
permissive · top 15,000 on PyPI
libarchive-clibarchive-c provides a Python interface to…
permissive · top 15,000 on PyPI
extractcodeExtracts a wide range of archive formats (tar,…
permissive · top 15,000 on PyPI
brotliProvides Python bindings to the Brotli…
permissive · top 1,000 on PyPI
rarfileReads RAR archive files (RAR3 and RAR5 formats)…
permissive · top 5,000 on PyPI
tzsttzst creates and extracts tar archives…
permissive · top 15,000 on PyPI
pyzstdProvides Python bindings to the Zstandard…
permissive · top 5,000 on PyPI
zipfile-deflate64Enables extraction of Deflate64-compressed ZIP…
permissive · top 5,000 on PyPI
unrarProvides Python access to RAR archive files…
copyleft · top 15,000 on PyPI