我创建了一个程序,可以从驱动器上的文件中读取某些数据,在PyQt5 ui上显示结果,并接受用户的更正(如果有)
该程序作为python文件运行时运行良好。但是,当我使用PyInstaller将其转换为独立的exe时,它可以正常工作,直到需要启动pyqt5 gui为止。此时,它将停止抛出以下错误:
qt.qpa.plugin:无法在“”中加载qt平台插件“windows”,即使找到它。此应用程序无法启动,因为无法初始化Qt平台插件。重新安装应用程序可能会解决此问题。可用的平台插件包括:最小化、屏幕外、windows。
gui的代码非常大,但结构如下:
from PyQt5 import uic, QtWidgets
import sys
import os
#baseUIClass, baseUIWidget = uic.loadUiType('gui.ui')
baseUIClass, baseUIWidget = uic.loadUiType(r'C:\mypath\gui.ui')
class Ui(baseUIClass, baseUIWidget ):
def __init__(self, *args, **kwargs):
baseUIWidget.__init__(self, *args, **kwargs)
self.setupUi(self)
# More code to perform the desired actions
def run(input_variables):
app = QtWidgets.QApplication(sys.argv)
ui = Ui()
ui.show()
# More code to make the Ui perform desired actions
app.exec_()
return(output_variables)
代码已转换为具有以下参数的独立exe:
pyinstaller --hiddenimport <hidden import> --onefile <python filename>
你知道怎么解决这个问题吗
谢谢
我在编译的应用程序中遇到了相同的错误消息
为了解决这个问题,我首先将应用程序简化为框架,只需最少的导入,编译后就可以完美地工作。然后,我部分地添加回我的“大”应用程序的所有导入,直到错误再次出现
最后(至少对我来说)熊猫是罪魁祸首:
例如,这项工作:
这(在第2行中添加的导入)引发您描述的错误:
但是,当首先导入pandas,然后导入PyQt 5时,我的编译版本再次工作:
因此,在我的案例中,解决方案是追踪“错误的进口”,摆弄进口订单并获得好运(我太没有经验了,甚至无法试图理解为什么进口订单会导致这种错误)
如果您不使用pandas,可能整个“剥离到骨架并开始逐块导入”方法将帮助您进一步澄清错误的根本原因
如果您使用的是pandas,而order开关up没有帮助,there is another thread它描述了尝试处理pandas编译问题的方法
相关问题 更多 >
编程相关推荐