如何使我的 python 脚本易于移植?或者如何编译成具有所有模块依赖项的二进制文件?

How to make my python script easy portable? or how to compile into binary with all module dependencies?(如何使我的 python 脚本易于移植?或者如何编译成具有所有模块依赖项的二进制文件?)
本文介绍了如何使我的 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 脚本易于移植?或者如何编译成具有所有模块依赖项的二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to find element by part of its id name in selenium with python(如何使用python在selenium中通过其id名称的一部分查找元素)
NoSuchElementException: Message: Unable to locate element while trying to click on the button VISA through Selenium and Python(NoSuchElementException:消息:尝试通过 Selenium 和 Python 单击 VISA 按钮时无法找到元素) - IT屋-程序员软件开发技术分
Selenium not able to click on Get Data button on using Python(Selenium 在使用 Python 时无法单击“获取数据按钮)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable with Selenium and Python(selenium.common.exceptions.ElementClickInterceptedException:消息:元素点击被拦截:元素不可点击
Selenium Compound class names not permitted(不允许使用硒化合物类名称)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element while trying to click Next button with selenium(selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:尝试使用 selenium 单