使用cx-freeze构建PySide程序osx的奇怪错误 [英] Strange error using cx-freeze to build a PySide program osx
问题描述
我正在通过 anaconda python发行版安装的运行python 2.7.8的64位Mac上使用cx-freeze4.3.3.该程序非常简单,如下所示:
I am using cx-freeze4.3.3 on a 64-bit mac running python 2.7.8 installed via the anaconda python distribution. The program is very simple as follows:
import sys
from PySide.QtGui import QApplication, QDialog
app = QApplication(sys.argv)
form = QDialog()
form.show()
app.exec_()
setup.py文件是标准文件,包括以下内容:
The setup.py file is standard, with the following included:
options = {
'build_exe': {
'includes': 'atexit'
}
}
executables = [
Executable('test.py', base=base)
]
运行 python setup.py build
时,发生以下错误:
When running python setup.py build
, the following error occurs:
复制libpython2.7.dylib->build/exe.macosx-10.5-x86_64-2.7/libpython2.7.dylib错误:[错误2]没有这样的文件或目录:'libpython2.7.dylib'
这里可能是什么问题?libpython2.7.dylib位于系统路径中的/anaconda/lib中.
What could be the issue here? libpython2.7.dylib is located in /anaconda/lib, which is in the system path.
推荐答案
我在OSX上遇到cx_freeze的类似问题,找不到要复制的文件.我在某个论坛上找到了解决方案(无法再次找到它):在cx_freeze文件 freezer.py
中的函数 _GetDependentFiles
中添加以下行:
I had a similar problem with cx_freeze on OSX not finding some files to be copied. I found the solution in some forum (cannot find it again):
add the following lines in function _GetDependentFiles
in cx_freeze file freezer.py
:
for i in range(len(dependentFiles)):
filei = dependentFiles[i]
if not os.path.isabs(filei):
print 'TD bug fix: adding ' + sys.prefix + '/lib to relative path ' + filei + '!'
dependentFiles[i] = os.path.join(sys.prefix,'lib',filei)
现在 python setup.py build
运行,但是构建的程序无法正确运行!可能您将遇到相同的问题,而我无法解决.所以我已经发布了这个问题:
Now python setup.py build
runs BUT the built program does not run correctly!! Probably you will have the same problem, which i could not solve. So i have posted the issue: Failed making a standalone python/Qt application with cx_freeze (or Py2App) on Mac and am hoping for an answer...
这篇关于使用cx-freeze构建PySide程序osx的奇怪错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!