Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my python script easy portable? or how to compile into binary with all module dependencies?

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?

like image 399
andriyko Avatar asked Dec 29 '10 17:12

andriyko


1 Answers

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]

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.

like image 186
Lennart Regebro Avatar answered Oct 13 '22 17:10

Lennart Regebro