The --hidden-import flag in PyInstaller is used to add a module that is not explicitly imported by the main script or any of its dependencies. This is useful for cases where a module is imported dynamically at runtime or when PyInstaller is unable to detect the module automatically.