PyInstaller和PySide,如何包含imageformats文件夹?

问题描述 投票:3回答:2

一个小时内问两个问题,我感到很难过,但是很好。

我正在使用Python和PySide构建一个相当复杂的应用程序。终于,发布的日子快到了,所以我想将此应用程序构建为exe。我正在使用PyInstaller构建我的exe二进制文件。

此应用程序的一部分加载一些JPEG图像。我在将这些图像加载到应用程序时遇到了问题(它们不会显示),所以我必须这样做:

path = os.getcwd()
app.addLibraryPath(path) #app being QApplication()

这使它起作用(此路径包含imageformats文件夹,其中包含qjpeg4.dll和其他图像加载插件)

但是,现在用PyInstaller打包时遇到了同样的问题。我必须使用--onefile标志,但是即使我不使用它,我也可以看到PyInstaller不包含imageformats文件夹-找不到位置。

我知道这是问题所在,因为当我手动将imageformats文件夹复制/粘贴到exe所在的文件夹中时,该应用程序将按预期工作。

是否有办法force PyInstaller包含我指定的文件夹,特别是此imageformats文件夹?

python qt pyside pyinstaller
2个回答
0
投票

使用PyInstaller --additional-hooks-dir=HOOKSDIR时有一个选项,它将其他目录附加到pyinstaller搜索路径中。


0
投票

PyInstaller的选项--add-data <SRC;DEST or SRC:DEST>

pyinstaller --add-data "\path\of\imageformats;imageformats" target.py
© www.soinside.com 2019 - 2024. All rights reserved.