Python to exe in 1 file

你离开我真会死。 提交于 2019-12-10 18:34:29

问题


So far i have used cx_freeze to convert py to exe but i get many files. Is there a way to get it all into 1 executable?

I have seen that PyinstallerGUI is able to that but it is for python 2.7. Can it be done with python 3.4 as well?

Thank you all.


回答1:


Pyinstaller works up to python 3.5. Once you've installed it (type in your terminal pip install pyinstaller), you can do in your terminal: pyinstaller --onefile script.py where script.py is the name of script you want to compile into .exe

with --onefile option it will create only one .exe file




回答2:


I haven't tried it but, PyInstaller says here it can do that and it supports Python 2.7 and Python 3.3+.

Quoting from the linked page:

PyInstaller can bundle your script and all its dependencies into a single executable named myscript (myscript.exe in Windows).

The advantage is that your users get something they understand, a single executable to launch. A disadvantage is that any related files such as a README must be distributed separately. Also, the single executable is a little slower to start up than the one-folder bundle.

Before you attempt to bundle to one file, make sure your app works correctly when bundled to one folder. It is is much easier to diagnose problems in one-folder mode.




回答3:


I found this on the PyInstaller Docs: pyinstaller --onefile your-python-file.py To find more: PyInstaller Docs



来源:https://stackoverflow.com/questions/38024935/python-to-exe-in-1-file

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