How to fix "ImportError: unable to find Qt5Core.dll on PATH" after pyinstaller bundled the python application

As detailed in the question, when startup the bundled application in the conda console, it runs properly, all the loaded DLLs, exported by ProcessExplorer, are in the dist dir which was created by pyinstaller. So the problem is that the path, containing pyqt DLLs, is not in the system's PATH environment. Maybe this is a bug of pyinstaller. The Solution is add the program path to system PATH env manually.

Here is the code snip i am using:

# Fix qt import error
# Include this file before import PyQt5 

import os
import sys
import logging


def _append_run_path():
    if getattr(sys, 'frozen', False):
        pathlist = []

        # If the application is run as a bundle, the pyInstaller bootloader
        # extends the sys module by a flag frozen=True and sets the app
        # path into variable _MEIPASS'.
        pathlist.append(sys._MEIPASS)

        # the application exe path
        _main_app_path = os.path.dirname(sys.executable)
        pathlist.append(_main_app_path)

        # append to system path enviroment
        os.environ["PATH"] += os.pathsep + os.pathsep.join(pathlist)

    logging.error("current PATH: %s", os.environ['PATH'])


_append_run_path()


Assuming you don't absolutely need PyQt5 version 5.13.0, the easiest fix is to simply downgrade PyQt5 to version 5.12.2 using:

pip install pyqt5==5.12.2

and your executable will work as expected.


Ran into the same issue after upgrade to Qt5.13.
Found this solution on pyinstaller github
You need to modify the .spec file and put the following:

datas=[(HOMEPATH + '\\PyQt5\\Qt\\bin\*', 'PyQt5\\Qt\\bin')],