2016-05-16 102 views
0

我想将我的Python应用程序转换为可执行文件,我发现cx_Freeze最容易修改并将其用于我的需要。cx_Freeze无法找到QtDesigner框架

这是我setup.py脚本:

from cx_Freeze import setup, Executable 

includefiles = ['Leaderboard.txt'] 
includes = ['PyQt4.QtGui', 'PyQt4.QtCore', 'functools.partial', 'multiprocessing.Process', 'sys'] 


setup(
    name = 'App', 
    version = '1.0', 
    description = 'Description', 
    author = 'ShellRox', 
    options = {'build_exe': {'include_files':includefiles}}, 
    executables = [Executable('Project.py', copyDependentFiles=True)] 
) 

的完整代码here


出于某种原因,我得到这个错误:

error: [Errno 2] No such file or directory: 'QtDesigner.framework/Versions/4/QtDesigner' 

完整的日志here

但是我不完全肯定能问题是什么,做了一些研究之后,我发现只有一个结果匹配我的问题,它不会在所有帮助(我已经删除的包虽然)。

我还在includes中只添加子模块,但它仍然没有帮助,我猜测它不是在寻找模块。

有一两件事让我奇怪的是,如果有跟我reseources.py文件关联的东西。

我也尝试将QtDesigner位置文件添加到路径,它没有更新任何其他进程。

问题:

问题是什么?我怎样才能黑名单它cx_Freeze所以它不会搜索QtDesigner框架(如果不是很有用),或者我是否需要在路径中添加的位置,以便可以寻找Qt设计(如果是这样,则路径会在哪里?)。

回答

0

cx_Freeze有一个选项来排除二进制文件。使用该选项可以阻止搜索不需要的二进制文件。 从文档

bin_excludes - list of names of files to exclude when determining dependencies of binary files that would normally be included; note that version numbers that normally follow the shared object extension are stripped prior to performing the comparison

添加该选项到你的setup.py文件build_exe选项里面这样

build_exe_options = { 
    "icon": iconPath, 
    "packages": packages, 
    "includes": includes, 
    "include_files": include_files, 
    "excludes": excludes, 
    "optimize": True, 
    "bin_excludes": ["QtDesigner"], 
    } 

但是,如果你的代码实际上需要一个可执行文件?如果您使用'otool'查看依赖关系,您可能会发现PySide.QtUiTools模块需要qtdesigner。

$ otool -L ~/lib/python2.7/site-packages/PySide/QtUiTools.so 
/lib/python2.7/site-packages/PySide/QtUiTools.so: 
    @rpath/libpyside-python2.7.1.2.dylib (compatibility version 1.2.0, current version 1.2.2) 
    /usr/local/lib/QtDesigner.framework/Versions/4/QtDesigner (compatibility version 4.8.0, current version 4.8.6) 
    /usr/local/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.6) 
    /usr/local/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.6) 
    @rpath/libshiboken-python2.7.1.2.dylib (compatibility version 1.2.0, current version 1.2.2) 
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0) 
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1) 

所以你最好找地方QtDesigner位于并使用“install_name_tool”搜索路径更改为QtUiTools.so模块的正确位置。

相关问题