如何让我的python脚本容易携带?或者如何编译与所有模块依赖二进制? [英] how to make my python script easy portable? or how to compile into binary with all module dependencies?

查看:132
本文介绍了如何让我的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]

但是如前所述,您还可以创建和分发有其他包作为依赖软件包。然后,您可以使用 PIP 来安装该软件包,它会安装所有的软件包。你还需要安装Python和点子,虽然。

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脚本容易携带?或者如何编译与所有模块依赖二进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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