【问题标题】:Support QtCore library path in PyInstaller在 PyInstaller 中支持 QtCore 库路径
【发布时间】:2015-03-29 22:06:25
【问题描述】:

我刚刚找到了一种支持 QtCore 中所有图像格式的方法,如下所示

from PySide imnport QtCore...

QtCore.QCoreApplication.addLibraryPath(os.path.join(os.path.dirname(QtCore.__file__), "plugins"))

但是,当我在 Windows 下使用 PyInstaller 构建应用程序时,我仍然遇到支持 JPEG/BPM 的问题...看起来此路径未添加到已编译的应用程序中。

如何添加?

【问题讨论】:

    标签: python qt python-2.7 pyside pyinstaller


    【解决方案1】:

    基于http://qt-project.org/wiki/Packaging_PySide_applications_on_Windows的简单想法

    我在app.spec 文件中添加了以下代码:

    from PySide import QtCore
    
    plugins=os.path.join(os.path.dirname(QtCore.__file__), "plugins\\imageformats")
    static_files += Tree(plugins, 'plugins\\imageformats')
    

    app.py(主格式):

    QtCore.QCoreApplication.addLibraryPath(os.path.join(os.path.dirname(QtCore.__file__), "plugins"))
    

    一切正常!

    【讨论】:

    • 如果这为您解决了问题,您可以将此答案标记为解决方案,以便其他人可以看到此问题已成功回答。
    猜你喜欢
    • 2020-05-01
    • 1970-01-01
    • 2014-07-05
    • 1970-01-01
    • 2011-03-08
    • 1970-01-01
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多