How to convert multiple python files to EXE?

一世执手 提交于 2020-05-15 07:17:22

问题


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


回答1:


For example in PyInstaller, you can specify additional folders which should be involved in your executable file.




回答2:


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.

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

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.

Edit:

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?

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



来源:https://stackoverflow.com/questions/41729062/how-to-convert-multiple-python-files-to-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!