【问题标题】:Cx_Freeze - How to Include ModulesCx_Freeze - 如何包含模块
【发布时间】:2012-05-09 08:06:59
【问题描述】:

我在将内容包含到我的 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)])

所以我真正需要知道的是如何将 Includes["sys", "easyGUI"] 合并到安装脚本中:D

【问题讨论】:

  • 你看到了什么问题?如果您正常导入它们,它应该会自动检测它们以包含它们。
  • 我设法收集到,当我构建它时它说?缺少模块:从 main 导入的 Easygui 当我运行 .exe 时它说没有名为 easygui 的模块,很可能引用了第一行代码:import easygui as eg
  • 这意味着它知道它应该包含easygui,但没有找到它来复制。 easygui 安装在哪里/如何安装?
  • easygui 安装在 D:\easygui
  • 如果您在安装脚本所在的位置启动 python,import easygui 是否有效?你需要把它放在某个地方以便它工作。我认为它通常类似于C:/Python27/Lib/site-packages,但我不使用 Windows,所以看看周围。

标签: python include cx-freeze


【解决方案1】:

说真的,我想你只是错过了告诉 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)])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-28
    • 2015-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多