Pyminizip
Pyminizip is a Python wrapper for the minizip library, designed specifically to create password-encrypted ZIP files. It also provides functionality to uncompress these password-protected archives. The current version is 0.2.6. The project appears to be in maintenance mode with infrequent updates, as its last release was in December 2021.
Warnings
- gotcha On Windows, `pyminizip` often requires Microsoft Visual C++ 14.0 or greater (i.e., MSVC build tools) to compile during installation, as it is a C extension wrapper. Installation via `pip` may fail without these tools installed.
- gotcha The project is explicitly marked as 'Inactive' in terms of maintenance, with no new versions released in the past 12 months (as of February 2026, last release was Dec 2021) and limited community activity. This indicates a potential lack of ongoing development, security updates, or bug fixes.
- gotcha Users have reported issues with non-ASCII characters (e.g., Chinese filenames) in file paths leading to errors, especially on Windows platforms, due to encoding challenges in the underlying C library wrapper.
- gotcha On Linux environments, `pyminizip` may encounter `ImportError` due to 'GLIBC_2.33' (or similar) not found errors. This typically indicates a mismatch between the GLIBC version used to compile the library and the GLIBC version available on the target system, common in containerized or diverse Linux environments.
- gotcha Despite reaching version 0.2.6, the PyPI classifiers for `pyminizip` indicate its development status as '3 - Alpha'. This suggests the maintainer considers the project to be in an early, experimental stage, implying potential instability or API changes without strict adherence to semantic versioning.
Install
-
pip install pyminizip
Imports
- pyminizip
import pyminizip
Quickstart
import pyminizip
import os
# Create dummy files for demonstration
with open("file1.txt", "w") as f:
f.write("This is file one.")
zip_filename = "my_archive.zip"
password = "supersecretpassword"
extract_dir = "extracted_files"
# 1. Compress a single file with password
pyminizip.compress(
"file1.txt",
None, # Prefix path (None to use relative path)
zip_filename,
password,
5 # Compression level (0 for default, 1-9 for speed/compression balance)
)
print(f"'{zip_filename}' created with password protection from 'file1.txt'.")
# 2. Extract the password-protected zip
os.makedirs(extract_dir, exist_ok=True)
pyminizip.uncompress(
zip_filename,
password,
extract_dir,
0 # Not specifying 'withoutpath'
)
print(f"'{zip_filename}' uncompressed to '{extract_dir}'.")
# Clean up dummy files and directories
os.remove("file1.txt")
os.remove(zip_filename)
os.remove(os.path.join(extract_dir, "file1.txt"))
os.rmdir(extract_dir)
print("Cleanup complete.")