Share via

how do i fix this

silk phenizy 0 Reputation points
2026-05-19T22:31:37.2433333+00:00

Traceback (most recent call last):

File "main.py", line 15, in <module>

File "PyInstaller\loader\pyimod02_importers.py", line 450, in exec_module

File "controller_init_.py", line 1, in <module>

from .launcher import LauncherController
```  File "PyInstaller\loader\pyimod02_importers.py", line 450, in exec_module

  File "controller\launcher.py", line 1, in <module>

```python
from PyQt6.QtWidgets import QApplication, QMainWindow, QTabWidget, QWidget, QVBoxLayout
```ImportError: DLL load failed while importing QtWidgets: The specified module could not be found.

Moved from Windows Insider

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-05-19T22:31:53.23+00:00

    The error indicates that the QtWidgets DLLs required by PyQt6 cannot be found when the frozen (PyInstaller) app runs.

    Use these steps to fix it:

    1. Verify PyQt6 is installed in the environment used to build
      • In the build environment run:
             python -m pip show PyQt6
        
      • If missing, install it:
             python -m pip install --upgrade PyQt6
        
    2. Rebuild with PyInstaller including PyQt6 plugins and DLLs
      • If using a .spec file, ensure PyQt6 is collected:
             from PyInstaller.utils.hooks import collect_all
             
             datas, binaries, hiddenimports = collect_all("PyQt6")
             
             a = Analysis(
                 ["main.py"],
                 ...,
                 datas=datas,
                 binaries=binaries,
                 hiddenimports=hiddenimports,
             )
        
      • If using the command line, try:
             pyinstaller --onefile --noconsole main.py --hidden-import PyQt6.QtWidgets
        
      • After rebuilding, run the generated EXE on the same machine to confirm it starts.
    3. Check for missing runtime dependencies on the target machine
      • Ensure the same (or compatible) Microsoft Visual C++ runtime is installed as on the build machine. Missing VC++ runtimes commonly cause Qt DLLs to fail to load.
      • Install the appropriate Visual C++ Redistributable (matching the Python/PyQt6 build) on the target system.
    4. Confirm all Qt DLLs are present next to the EXE
      • In the dist/<appname> folder, there should be:
        • PyQt6 package directory
        • Qt6*.dll files
        • platforms, styles, and other Qt plugin folders
      • If they are missing, adjust the PyInstaller spec as in step 2 to collect them.
    5. Test on a clean machine
      • Copy the entire dist/<appname> directory to a clean Windows machine and run the EXE.
      • If it fails only there, a missing system dependency (e.g., VC++ runtime) is the likely cause.

    If the problem persists, rebuild with a fresh virtual environment, reinstall PyQt6, regenerate the PyInstaller spec, and rebuild to ensure no stale paths or partial installs.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.