How to make my python script easy portable? or how to compile into binary with all module dependencies?(如何使我的 python 脚本易于移植?或者如何编译成具有所有模块依赖项的二进制文件?)
问题描述
有没有办法将python脚本编译成二进制?我有一个文件 python 脚本,它使用了很多模块.我想要的是在其他机器(freebsd)上拥有它的副本,但无需在每台主机上安装所有需要的模块.
Is there any way to compile python script into binary? I have one file python script which uses a lot of modules. What I would like is to have its copy on other machines (freebsd) but without installing all needed modules on every host.
在这种情况下有什么可能的解决方案?
What are possible solutions in such cases?
推荐答案
可以做你要求的程序有:
Programs that can do what you ask for are:
- PyInstaller:http://www.pyinstaller.org/ [Windows、Linux、OS X]
- cx_freeze:http://cx-freeze.sourceforge.net/ [Windows, Linux]
- py2exe:http://www.py2exe.org/ [Windows]
- py2app:http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html [os x]
- PyInstaller: http://www.pyinstaller.org/ [Windows, Linux, OS X]
- cx_freeze: http://cx-freeze.sourceforge.net/ [Windows, Linux]
- py2exe: http://www.py2exe.org/ [Windows]
- py2app: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html [os x]
但如前所述,您也可以使用 Distribute 创建一个包,并将其他包作为依赖项.然后你可以使用 pip
来安装那个包,它会安装所有的包.不过,您仍然需要安装 Python 和 pip.
But as mentioned you can also create a Package with Distribute and have the other packages as dependencies. You can then uses pip
to install that package, and it will install all of the packages. You still need to install Python and pip, though.
这篇关于如何使我的 python 脚本易于移植?或者如何编译成具有所有模块依赖项的二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使我的 python 脚本易于移植?或者如何编译成


基础教程推荐
- 求两个直方图的卷积 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 包装空间模型 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01