PyInstaller Hooks Contrib

2026.4 · active · verified Thu Apr 09

PyInstaller Hooks Contrib is a collection of community-maintained hooks that extend PyInstaller's ability to bundle complex Python applications. These hooks handle the specific packaging requirements of various third-party libraries, ensuring they work correctly when frozen into a standalone executable. The current version is 2026.4, with releases typically following a monthly cadence.

Warnings

Install

Imports

Quickstart

To demonstrate `pyinstaller-hooks-contrib`, create a simple application that uses a library known to require complex bundling (e.g., matplotlib). Install both `pyinstaller` and `pyinstaller-hooks-contrib`. When `pyinstaller` is run on the application, the `pyinstaller-hooks-contrib` library will be automatically detected and its hooks applied, ensuring the bundled application works correctly without manual intervention for common libraries.

import matplotlib.pyplot as plt
import numpy as np

def create_plot():
    x = np.linspace(0, 10, 100)
    y = np.sin(x)
    plt.plot(x, y)
    plt.title("Simple Sine Wave")
    plt.xlabel("X-axis")
    plt.ylabel("Y-axis")

if __name__ == "__main__":
    create_plot()
    print("Matplotlib imported successfully (for PyInstaller testing).")

# To use:
# 1. Save the above code as app.py
# 2. Ensure pyinstaller and pyinstaller-hooks-contrib are installed:
#    pip install pyinstaller pyinstaller-hooks-contrib
# 3. Run PyInstaller:
#    pyinstaller app.py
# PyInstaller will automatically use the hooks from pyinstaller-hooks-contrib to correctly bundle matplotlib and numpy.

view raw JSON →