如何将多个python文件转换为EXE? [英] How to convert multiple python files to EXE?

查看:350
本文介绍了如何将多个python文件转换为EXE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将python应用程序转换为exe.我见过py2exe和cx冻结之类的东西,但它们仅编译一个py文件.谁能帮我?谢谢

I am trying to convert my python application to an exe. I have seen things like py2exe and cx freeze, but they only compile one single py file. Can anyone help me? Thank you

推荐答案

我当前使用的是 pyinstaller ,用于将项目构建为单个可执行文件.这些项目都包含多个python(和一些非python)文件,这些文件都内置"在exe文件中.

I currently use pyinstaller for building projects into single-executable files. These projects all contain multiple python (and some non-python) files that are all "built into" the exes.

话虽如此,即使包含多个python文件, MarcusMüller是正确的.给定可执行文件只有一个入口点.

That being said, even with multiple python files included, Marcus Müller is correct. There is one entry point for a given executable.

总而言之,如果您将多个文件作为一个项目的一部分,则pyinstaller以及其他python捆绑程序将处理此情况. 如果您有多个文件,并且希望每个文件都成为自己的可执行文件,则需要将每个文件视为自己的项目",并分别打包.

In summary, if you have multiple files as part of a single project, pyinstaller along with the other python bundlers will handle this scenario. If you have multiple files and want them each to be their own executable file, you will need to treat each as its own 'project' and package each individually.

您定位到哪个平台?您可以描述文件的预期用途吗?您能描述这些文件的预期用途吗?

What platform(s) are you targeting? Can you describe the intended purpose of the files? Can you describe the intended usage of the files?

发布一个示例,说明您当前所拥有的,所观察到的行为以及澄清所期望与所观察到的东西之间的差异将肯定会帮助其他人引导您获得所需的答案.

Posting an example of what you currently have, what behavior you are observing, and clarification on what is different between what you are expecting and what you are observing would definitely help others in guiding you towards the answer you desire.

嗯,我有一个主要的python文件,该文件引用了一个非常简短的config.py.主文件还访问一些文本文件.我可以将config和main组合成一个py文件,并使其成为可执行文件,并且该可执行文件仍然可以访问文本文件吗?

Well, I have a main python file that is referenced to a very brief config.py. The main file also accesses a few text files. Could I just combine the config and the main into one py file, and make that an executable, and will that executable still have access to the text files?

您的主要python文件将是您exe的入口点.如果您将配置文件导入到主目录中,则pyinstaller应该会看到导入并包含它.在此行中,验证您的PATH环境变量,并确保您的系统知道从何处查找所需的位.如果文本文件将作为构建的可执行文件的一部分包含在内,则pyinstaller能够将文件也包含在构建中(例如,包含数据库,配置或静态数据集).描述包含构建图标文件的示例问题:

Your main python file would be your exe's entry point. If you import your config file into your main, pyinstaller should see the import and include it. On this line, verify your PATH environment variable, and insure your system knows where to find the bits it needs. If the text files are to be included as part of the built executable file, pyinstaller has the ability to include files into the build as well (example, include a database, a config, or a static data set). An example question describing including an icon file for a build: include-pyinstaller-icon

这篇关于如何将多个python文件转换为EXE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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