How to convert python .py file into an executable file for use cross platform?

前端 未结 4 638
礼貌的吻别
礼貌的吻别 2020-12-28 08:33

I\'ve been searching through SO for a while now trying to come up with an answer to this but due to my inexperience with programming I don\'t understand much of the document

4条回答
  •  無奈伤痛
    2020-12-28 09:15

    There are two distinct ways of freezing python scripts to create executables:

    1. Packing the interpreter and *.pyc files into one exe file-container. Such an approach is used by tools like PyInstaller, Py2exe, cx_freeze.
    2. Creating native code from Python source, usually using a middle step of converting Python-source to C or C++ code. This is done by such tools as Shed-skin and Nuitka. The problem of this aproach is that such tools do not always support all the functionality of Python (e.g. they can have some typing limitations and so on)

    The point where you have to start is reading the documentation. Such tools are not just push-and-run style tools, they usually have some configuration that must be implemented (that's the problem of possibly all build systems, and as the project grows, the configuration and number of hooks also grows).

    You can start with Py2exe tutorial and 'hello-world' to get acquainted with that how compilation is done. As far as I know it's a simplest way to get your goal.

    And the last thing, you can't create cross-platform native executables as their file formats are strongly operating system and hardware dependent.

提交回复
热议问题