pyunpack is a Python library that provides a simple interface for unpacking various archive file formats such as ZIP, RAR, and 7z. It primarily acts as a wrapper around the `patool` library, which in turn leverages external command-line unarchiving tools. If `patool` is not available or cannot handle a specific format, `pyunpack` falls back to Python's built-in `zipfile` module for ZIP archives. The current stable version is 0.3, released in June 2022, with an infrequent release cadence.
pip install pyunpackVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to unpack a simple ZIP archive using `pyunpack`. It includes steps to create a dummy ZIP file, extract its contents, verify the extraction, and clean up afterwards. For non-ZIP formats, ensure `patool` and the corresponding external unarchiving utilities are installed and accessible in your system's PATH.
Install the necessary command-line unarchivers (e.g., `sudo apt-get install unrar p7zip-full` on Linux) and ensure they are discoverable in your system's PATH.
Ensure you are running pyunpack in a Python 3 environment (Python 3.9+ is officially supported).
If encountering issues with `patool`, consider installing it directly from its GitHub repository: `pip install https://github.com/wummel/patool/archive/refs/heads/master.zip`.
Install the appropriate external unarchiver program for the format you are trying to extract. For `.rar` files, install `unrar`. For `.7z` files, install `7zip` (e.g., `p7zip-full` on Linux). Ensure the executable is in your system's PATH.
Run your code with a Python 3 interpreter. pyunpack 0.3 officially supports Python 3.9-3.12.
First, ensure all external unarchivers are correctly installed and in PATH (see first problem). If the issue persists, try installing `patool` directly from its GitHub repository to get the latest version: `pip install https://github.com/wummel/patool/archive/refs/heads/master.zip`.