brotlipy is a Python library that provides CFFI-based bindings to Google's Brotli lossless compression algorithm. It enables Python applications to efficiently compress and decompress data using Brotli, supporting both one-shot and streaming operations. Version 0.7.0 is the final release of this library, as the project has been archived and its development continues under the `brotlicffi` package.
pip install brotlipyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both one-shot and streaming compression/decompression using `brotlipy`. For one-shot operations, `brotli.compress()` and `brotli.decompress()` are used. For streaming, `brotli.Compressor()` and `brotli.Decompressor()` objects are initialized, and data is processed in chunks. Remember that `brotli.compress()` and `brotli.decompress()` expect and return byte strings.
Migrate to `brotlicffi`: `pip install brotlicffi`. Update imports from `import brotli` to `import brotlicffi`. Refer to `brotlicffi` documentation for any API changes.
Be aware of potential module name collisions. When migrating to `brotlicffi`, the import path changes to `import brotlicffi`.
Install the necessary system-level development packages before running `pip install brotlipy`. Examples: `sudo apt-get install build-essential python-dev libffi-dev` (Debian/Ubuntu) or `sudo yum install gcc libffi-devel python-devel` (Red Hat/CentOS).
Ensure dictionary bytes are identical for corresponding compression and decompression operations. Store and manage dictionaries carefully.
To resolve this, ensure only one Brotli-related package is installed. If you intend to use `brotlipy` (version 0.7.0), try reinstalling it (`pip uninstall brotlipy && pip install brotlipy`). If you require the newer `brotlicffi` or Google's `brotli` package, uninstall `brotlipy` and install the desired alternative (`pip uninstall brotlipy && pip install brotlicffi`) and adjust imports from `import brotli` to `import brotlicffi`.
Install the necessary build dependencies for your operating system. For Debian/Ubuntu, use `sudo apt-get install build-essential python3-dev libffi-dev` (adjust `python3-dev` for your Python version). For Red Hat/Fedora, use `sudo yum install gcc libffi-devel python3-devel`. After installing dependencies, try `pip install brotlipy` again.
First, ensure `brotlipy` is uninstalled (`pip uninstall brotlipy`). Then, try reinstalling it, ensuring all build dependencies are met (refer to the 'Failed building wheel' fix if installation issues persist). If using a virtual environment, make sure it's activated. As `brotlipy` is archived, consider migrating to `brotlicffi` (`pip install brotlicffi`) as its active successor.
Reinstall the `cffi` package explicitly: `pip uninstall cffi && pip install cffi`. If the problem persists, ensure your Python installation is healthy and that you have a C compiler and development headers installed, as `cffi` also requires compilation for its native components. In virtual environments, ensure `cffi` is installed within that environment.