rarfile is a Python library for reading RAR archives, providing a `zipfile`-like interface. It acts as a wrapper around external utilities like `unrar`, `7zip`, `unar`, or `unrar-free`. The project is actively maintained with regular updates and bug fixes.
pip install rarfileVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to open a RAR archive, list its contents, and shows commented-out examples for extracting files. It requires an external `unrar` binary (or similar) to be installed on your system and accessible via PATH for `rarfile` to function.
Install one of the supported external RAR utilities (e.g., `sudo apt-get install unrar` on Debian/Ubuntu, `brew install unrar` on macOS, or download from RARLAB for Windows) and ensure it's accessible via your system's PATH.
Adjust code to expect or strip trailing slashes for directory names. For example, `entry.filename.rstrip('/')` if you need the name without the slash.If these features are critical, consider using the external `unrar` tool directly or downgrading to a version prior to 4.0 (not recommended due to other improvements).
Always provide the correct password using the `pwd` argument when opening encrypted RAR files: `rarfile.RarFile(filename, 'r', pwd=b'your_password')`. Note that the password should be bytes.
Upgrade your Python environment to 3.8 or newer (3.12 is now supported and tested).
Install one of the required external utilities (e.g., `unrar` on Linux/macOS, 7-Zip on Windows) and ensure its executable is discoverable in your system's PATH. For example, on Ubuntu: `sudo apt-get install unrar`.
Ensure the file is a legitimate, uncorrupted RAR archive. If it's encrypted, `rarfile` might require the correct password, or the encryption might be of an unsupported type. Try opening the file with a standalone RAR extractor to confirm its integrity.
Provide the correct password when opening the RAR file or extracting its contents using the `pwd` parameter: `rf = rarfile.RarFile('archive.rar', pwd='your_password')` or `rf.extractall(pwd='your_password')`.Install the package using pip: `pip install rarfile`.
No dependency data recorded yet.