Cx_Freeze - 如何包含模块

时间:2012-05-09 08:07:00

标签: python include cx-freeze

我一直遇到这个问题,将内容包含在我的cx_Freeze脚本中,我试图做的是包括easygui和sys,因为我在我的程序中使用它们。任何帮助将不胜感激!

下面是代码:

import sys
from cx_Freeze import setup, Executable


build_exe_options = {"packages": ["os"], "excludes": ["tkinter"] }


base = None
if sys.platform == "win32":
base = "Win32GUI"

setup(  name = "ProgramGUI",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("ProgramGUI.py", base=base)])

所以我真正需要知道的是如何将包含[“sys”,“easyGUI”]纳入设置脚本:D

1 个答案:

答案 0 :(得分:2)

说真的,我觉得你只是想错一点告诉cx_freeze导入easy_gui:

import sys
from cx_Freeze import setup, Executable


build_exe_options = {
    "packages": ["os", "sys"], 
    "excludes": ["tkinter"],
    "includes": ["easy_gui"] # <-- Include easy_gui
}

base = None
if sys.platform == "win32":
base = "Win32GUI"

setup(  name = "ProgramGUI",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("ProgramGUI.py", base=base)])