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,代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

# 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

1

import fix_qt_import_error

  

回到顶部

四、解决方式2

1.参考文档:https://github.com/pyinstaller/pyinstaller/issues/2152

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

1

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值