用于两个或多个 python 文件(模块)的 Python cx_Freeze [英] Python cx_Freeze for two or more python files (modules)

查看:32
本文介绍了用于两个或多个 python 文件(模块)的 Python cx_Freeze的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有使用给定的 py 文件(模块)构建可执行文件的示例 这里 我有大约 4 个 py 文件(模块),我想构建一个包含所有 py 文件的可执行文件.

There are example to build executable using one py file(module) as given here I have about 4 py files(modules), I would like to build executable which should include all the py files.

当我们有多个 python 模块时如何构建 python 可执行文件?

How to build python executable when we have more then one python modules ?

来自此处的示例

    from cx_Freeze import setup, Executable

setup(
        name = "hello",
        version = "0.1",
        description = "the typical 'Hello, world!' script",
        executables = [Executable("hello.py")])

如果我有两个文件,比如 hello1.py 和 hello2.py ,这有 hello.py 吗?

This has hello.py if I have two files like hello1.py and hello2.py ?

谢谢

推荐答案

如果您的 hello.py 文件导入这些文件 - hello1.pyhello2.py,然后这一行:

If your hello.pyfile import those files - hello1.py and hello2.py, then this line:

executables = [Executable("hello.py")])

已经足够了.

但是如果这些文件中的任何一个是单独的脚本文件,那么您应该这样做:

But if any of those files are separate script file, then you should do like this:

from cx_Freeze import setup, Executable

setup(
        name = "hello",
        version = "0.1",
        description = "the typical 'Hello, world!' script",
        executables = [Executable("hello.py"), Executable("hello1.py"), Executable("hello2.py")]
)

它将为您的每个脚本创建 3 个 .exe 文件.

It will create 3 .exe files, for each one of your scripts.

这篇关于用于两个或多个 python 文件(模块)的 Python cx_Freeze的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆