Python cx_Freeze 两个或更多 python 个文件(模块)
Python cx_Freeze for two or more python files (modules)
有使用一个 py 文件(模块)构建可执行文件的示例 here 我有大约 4 个 py 文件(模块),我想构建应包含所有 py 文件的可执行文件。
当我们有多个 python 模块时如何构建 python 可执行文件?
示例来自 here
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?
谢谢
如果您的 hello.py
文件导入那些文件 - hello1.py
和 hello2.py
,则此行:
executables = [Executable("hello.py")])
够了。
但是如果这些文件中的任何一个是单独的脚本文件,那么您应该这样做:
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
文件。
有使用一个 py 文件(模块)构建可执行文件的示例 here 我有大约 4 个 py 文件(模块),我想构建应包含所有 py 文件的可执行文件。
当我们有多个 python 模块时如何构建 python 可执行文件?
示例来自 here
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?
谢谢
如果您的 hello.py
文件导入那些文件 - hello1.py
和 hello2.py
,则此行:
executables = [Executable("hello.py")])
够了。
但是如果这些文件中的任何一个是单独的脚本文件,那么您应该这样做:
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
文件。