Is there a way to compile a python application into static binary?

前端 未结 5 742
醉酒成梦
醉酒成梦 2020-12-04 05:45

What I\'m trying to do is ship my code to a remote server, that may have different python version installed and/or may not have packages my app requires.

Right now t

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 06:29

    Freeze options:

    • https://pypi.python.org/pypi/bbfreeze/1.1.3
    • http://cx-freeze.sourceforge.net/

    However, your target server should have the environment you want -> you should be able to 'create' it. If it doesn't, you should build your software to match the environment.

    I found this handy guide on how to install custom version of python to a virtualenv, assuming you have ssh access: https://stackoverflow.com/a/5507373/5616110

    In virtualenv, you should be able to pip install anything and you shouldn't need to worry about sudo privileges. Of course, having those and access to package manager like apt makes everything a lot easier.

提交回复
热议问题