{"id":1650,"library":"pyinstaller-hooks-contrib","title":"PyInstaller Hooks Contrib","description":"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.","status":"active","version":"2026.4","language":"en","source_language":"en","source_url":"https://github.com/pyinstaller/pyinstaller-hooks-contrib","tags":["packaging","deployment","bundling","pyinstaller","hooks","application-freezing"],"install":[{"cmd":"pip install pyinstaller pyinstaller-hooks-contrib","lang":"bash","label":"Install PyInstaller with Hooks Contrib"}],"dependencies":[{"reason":"Provides community-maintained hooks that are automatically discovered and used by PyInstaller during the bundling process.","package":"PyInstaller","optional":false}],"imports":[{"note":"Users do not directly import symbols from `pyinstaller-hooks-contrib`. Its functionality is integrated into PyInstaller when present in the environment.","symbol":"Not Applicable","correct":"This library provides hooks that PyInstaller automatically discovers and uses during the build process. Direct imports of `pyinstaller-hooks-contrib` in user application code are not performed."}],"quickstart":{"code":"import matplotlib.pyplot as plt\nimport numpy as np\n\ndef create_plot():\n    x = np.linspace(0, 10, 100)\n    y = np.sin(x)\n    plt.plot(x, y)\n    plt.title(\"Simple Sine Wave\")\n    plt.xlabel(\"X-axis\")\n    plt.ylabel(\"Y-axis\")\n\nif __name__ == \"__main__\":\n    create_plot()\n    print(\"Matplotlib imported successfully (for PyInstaller testing).\")\n\n# To use:\n# 1. Save the above code as app.py\n# 2. Ensure pyinstaller and pyinstaller-hooks-contrib are installed:\n#    pip install pyinstaller pyinstaller-hooks-contrib\n# 3. Run PyInstaller:\n#    pyinstaller app.py\n# PyInstaller will automatically use the hooks from pyinstaller-hooks-contrib to correctly bundle matplotlib and numpy.","lang":"python","description":"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."},"warnings":[{"fix":"Always install `pyinstaller-hooks-contrib` alongside `pyinstaller` to ensure broad compatibility: `pip install pyinstaller pyinstaller-hooks-contrib`.","message":"Many popular third-party libraries (e.g., PyQt, Kivy, matplotlib, scipy) will fail to build or run correctly when bundled with PyInstaller if `pyinstaller-hooks-contrib` is not installed, as it provides essential community-maintained hooks for these packages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Periodically update both packages: `pip install --upgrade pyinstaller pyinstaller-hooks-contrib`.","message":"While not strictly tied, ensure that your `pyinstaller-hooks-contrib` version is relatively up-to-date with your `PyInstaller` version. Newer PyInstaller versions might expect newer hook definitions, and older `contrib` versions could lead to build issues.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If a build fails for a newly updated library, check the `pyinstaller-hooks-contrib` GitHub issues for updates, or temporarily pin the problematic library to an older version known to work with the current hooks.","message":"Hooks for a specific library within `pyinstaller-hooks-contrib` might occasionally lag behind very recent versions of that third-party library. This can lead to bundling issues even with the contrib package installed.","severity":"gotcha","affected_versions":"All versions, specific to new library releases"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}