{
  "id": 6674394,
  "title": "What are PyInstaller \"hidden imports\" — and why do only dynamic imports break?",
  "url": "https://urgent.news/2026/09/11/what-are-pyinstaller-hidden-imports-and-why-do-only-dynamic-imports",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-11T00:21:07.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/susumun/what-are-pyinstaller-hidden-imports-and-why-do-only-dynamic-imports-break-gid"
  },
  "original_language": "en",
  "account": "PyInstaller is a tool that bundles Python scripts and their dependencies into a single executable, allowing end users to run the app without needing a Python environment. The tool analyzes the source code to determine which modules are needed, but it doesn't execute the code to do this. As a result, any module that is only referenced dynamically during runtime may not be detected, leading to hidden import issues.\n\nThese hidden imports usually occur in three scenarios: code that constructs import strings at runtime, dynamic scanning for plugins, or modules loaded by third-party packages with conditional loading. These dynamic imports or function-scoped imports can lead to ModuleNotFoundError when the app is frozen into an executable. The issue doesn't always manifest during the development process, as the code may still run, displaying the wrong value or triggering a fallback path rather than crashing.\n\nTo address this issue, PyInstaller offers a few solutions: using the --hidden-import command line argument, specifying the hiddenimports argument in the .spec file, or writing a dedicated hook file for third-party packages. By explicitly listing all potentially hidden imports, developers can ensure that their applications run correctly without unexpected ModuleNotFoundError exceptions, preventing silent bugs that only reveal themselves during runtime.",
  "summary": "If you've ever packaged a Python desktop app with PyInstaller, you may have run into this: the app runs perfectly from source, but the frozen executable throws ModuleNotFoundError — and only when you exercise one particular feature. It doesn't crash on startup. It crashes three clicks deep, in a code path nobody happened to test right after the build. This post breaks down why that happens and…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}