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

后端 未结 4 1731
谎友^
谎友^ 2020-12-24 15:32

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 (fr

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-24 16:12

    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.

提交回复
热议问题