skillfed

py7zr

Pure python 7-zip library

py7zr v1.1.3 9.6M downloads/30d#1,519 on PyPI557
Copyleft license LGPL-2.1-or-later Active released

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 py7zr

uv

uv add py7zr

poetry

poetry add py7zr

Installing 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

Development Status :: 5 - Production/StableOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

7z archive compression decompression7zip library pythonlzma zstandard brotli compressionencrypted archive handlingmulti-volume archive creationpassword-protected 7z files
compressionarchive-formatencryption

More Python Modules packages