【问题标题】:How to convert Python project into executable如何将 Python 项目转换为可执行文件
【发布时间】:2018-11-30 11:46:03
【问题描述】:

我有一个 Python 项目,我想将其转换为可执行文件。我已经安装了 Pyinstaller。我只知道如何将一个脚本转换成 .exe,但我有多个包含多个 python 脚本的包。

【问题讨论】:

    标签: python project executable pyinstaller


    【解决方案1】:

    我使用成功的命令行是:

    pyinstaller --noupx --onefile --add-data="cprofiles.ui;." cprofiles_lmfit.py
    

    pyinstaller 对您导入的多个 '.py' 文件进行了相对较好的管理,无需引用它们。在“添加数据”选项下,您列出了非 py 文件,在我的示例中,“cprofiles_lmfit.py”文件是包含主文件的文件。

    但正如need help to compile python with pyinstaller (以及其他几篇文章)所指出的,我是 pyinstaller 的初学者。我永远无法使用“theano”模块,也没有进行优化。我仍然需要测试答案中的建议。

    【讨论】:

      【解决方案2】:

      将主脚本转换为 .exe 应该可以解决问题,使用 -onefile 将其转换为一个 exe,其余的 .py 文件应该包含在内。

      【讨论】:

        【解决方案3】:

        1) 打开命令提示符

        2) 安装 pyinstaller 点安装 pyinstaller

        3) 首先测试你的 python 脚本只是为了检查 python 脚本是否可以正常工作 .py 扩展名。 Saurabh 是 python 文件的名称 python saurabh.py

        4) 将python转换成可执行文件 pyinstaller --onefile Saurabh.py

        请注意,我们已将“–onefile”作为参数传递,告诉 pyinstaller 只创建一个文件

        5) 转到目录并导航到 dist 文件夹。

        先决条件:安装 PyQt5 以避免错误。 点安装 PyQt5

        【讨论】:

        • 问题指定了整个项目而不是一个脚本。问题还表示用户知道如何使用 --onefile 并且没有尝试这样做。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-05
        • 2020-09-27
        相关资源
        最近更新 更多