Strange error using cx-freeze to build a PySide program osx

左心房为你撑大大i 提交于 2019-12-11 12:55:02

问题


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_()

The setup.py file is standard, with the following included:

options = {
    'build_exe': {
        'includes': 'atexit'
    }
}

executables = [
    Executable('test.py', base=base)
]

When running python setup.py build, the following error occurs:

copying libpython2.7.dylib -> build/exe.macosx-10.5-x86_64-2.7/libpython2.7.dylib error: [Errno 2] No such file or directory: 'libpython2.7.dylib'

What could be the issue here? libpython2.7.dylib is located in /anaconda/lib, which is in the system path.


回答1:


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)

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...



来源:https://stackoverflow.com/questions/27256937/strange-error-using-cx-freeze-to-build-a-pyside-program-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!