适用于两个或更多python文件(模块)的Python cx_Freeze

发布于 2021-01-29 15:05:47

有一个使用一个py文件(模块)构建可执行文件的示例,如下所示我大约有4个py文件(模块),我想构建应包含所有py文件的可执行文件。

当我们有一个以上的python模块时,如何构建python可执行文件?

这里的例子

    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?

谢谢

关注者
0
被浏览
88
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    如果您的hello.py文件导入了这些文件-hello1.pyhello2.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")]
    )
    

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



知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看