python 创建单个python可执行模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1999129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create single python executable module
提问by yart
Guys, I have much python code in modules which are resides in several python packages and now I need to create single python executable module or file which will include all these files, so it will be working on windows and on linux servers. What are possible solutions and how this can be done?
伙计们,我在模块中有很多 python 代码,它们驻留在多个 python 包中,现在我需要创建单个 python 可执行模块或文件,其中将包含所有这些文件,因此它将在 windows 和 linux 服务器上运行。什么是可能的解决方案以及如何做到这一点?
采纳答案by S.Lott
That's what egg files are for. Read this: What are the advantages of packaging your python library/application as an .egg file?
这就是egg文件的用途。请阅读:将您的 Python 库/应用程序打包为 .egg 文件有什么优势?
回答by Anurag Uniyal
For windows use py2exe, for linux use pyinstallerand for Mac use py2app
windows 使用py2exe,linux 使用pyinstaller,Mac 使用py2app
Using these tools you can have a setup.py
which based on os will build the final binary.
使用这些工具,您可以使用setup.py
基于 os 的工具来构建最终的二进制文件。
I have tried all three and they work well, or you can use cx_freezethey claim to be cross-platform
我已经尝试了所有三个并且它们运行良好,或者您可以使用他们声称是跨平台的cx_freeze
回答by miku
Maybe py2execan help you ..
也许py2exe可以帮助你..
py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.
py2exe 是 Python Distutils 扩展,可将 Python 脚本转换为可执行的 Windows 程序,无需安装 Python 即可运行。
Tutorial > http://www.py2exe.org/index.cgi/Tutorial