Failed to build stand-alone application on Mac OS X Yosemite (10.10) with cx_Freeze

吃可爱长大的小学妹 提交于 2019-12-07 17:10:58

问题


I tried to build an application with cx_Freeze 4.3.1 on Mac OS X Yosemite 10.10 but it didn't worked. I use python version 2.7 and use Tkinter as my GUI for development. If I use python setup.py bdist_macon the terminal, the build process fail with the following error message:

[Errno2]/Library/Frameworks/Tcl.framework/versions/8.5/TCL no such file or directory

The newest version (8.5) of Tcl/Tk is already installed.

My setup file looks like this:

from cx_Freeze import setup, Executable
build_exe_options = {
"includes": [],
"packages": [],
'excludes' : ['collections.abc', 'urllib.sys'],
"include_files": []}

setup(
    name = "application",
    version = "0.1",
    description = "",
    author = "",
    options = {"build_exe": build_exe_options},
    executables = [Executable("applicaton.py")]
)

Does anyone know what I can do to get it working? Thanks in advance!


回答1:


I recommend you do a few things here (hopefully solving two issues I can identify):

  • Using Mac OS X's system Python (not recommended)
  • Using old and unmaintained cx_Freeze

First let's fix your Python installation! The recommended approach is to use Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update
brew install python

Now you should have a good installation of Python in /usr/local that's separate from your Mac OS X system Python so you can keep things clean and separate. You should also have followed any recommended instructions from the above installation. Typically this involves modifying your $PATH:

export PATH="/usr/local/bin:$PATH"

Note: Normally you should modify your $HOME/.bashrc or $HOME/.profile depending on how you have your Terminal configured.

You should now also have pip form /usr/local/bin/pip available as well.

Now on to a better replacement for cx_freeze -- The recommended and more maintained approach these days is to use pyInstaller:

pip install pyinstaller
pyinstaller -F /path/to/my/script.py

For more complex requirements and builds please follow pyinstaller's documentation on Using sepc files

Good luck!

Note: This should also fix your TCL/TK problem as well hopefully!



来源:https://stackoverflow.com/questions/30386732/failed-to-build-stand-alone-application-on-mac-os-x-yosemite-10-10-with-cx-fre

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