适用于两个或更多python文件(模块)的Python cx_Freeze [英] Python cx_Freeze for two or more python files (modules)
问题描述
有给出使用一个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 ?
谢谢
推荐答案
如果您的你好.py
file导入这些文件- hello1.py
和 hello2.py
,然后输入行:
If your hello.py
file 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屋!