ImportError: unable to find Qt5Core.dll on PATH


一、實驗環境

1.Windows7x32_SP1

2.python3.7.4

3.pyinstaller3.5

二、問題描述

1.一直都是在Windows10x64上使用pyinstaller打包exe程序,發現exe程序在Windows7x32上無法正常運行。

想起之前某位大神的建議,打包exe程序時最好在32位系統上

2.部署如上實驗環境,pyinstaller打包時報錯:ImportError: unable to find Qt5Core.dll on PATH

三、解決方式1

1.參考文檔:https://stackoverflow.com/questions/56949297/how-to-fix-importerror-unable-to-find-qt5core-dll-on-path-after-pyinstaller-b

2.新建fix_qt_import_error.py,代碼如下:

# 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()

3.主程序導入PyQt5相關庫之前導入fix_qt_import_error.py

import fix_qt_import_error

  

四、解決方式2

1.參考文檔:https://github.com/pyinstaller/pyinstaller/issues/2152

2.pyinstaller命令中添加--path參數,示例如下:

pyinstaller --path C:\Python35-32\Lib\site-packages\PyQt5\Qt\bin test.py

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM