How to reduce cx_Freeze compiled Python executable size?

前端 未结 1 787
温柔的废话
温柔的废话 2021-01-15 23:57

I\'ve compiled a Python program with cx_Freeze. The Python code itself is only 195 lines long. However, my compiled program is 500 MB. I use matp

1条回答
  •  再見小時候
    2021-01-16 00:41

    Part of the purpose of cx_Freeze is to bundle all the dependencies, so that the end user need not install them. numpy, matplotlib, etc. are not small dependencies, especially because they have large binary (non-Python) components. So what you are asking is not physically possible, not because of cx_Freeze limitations, but because of a contradiction between the following two requirements:

    • end user should be able to run executable on essentially any Windows machine, including possibly one without Python, numpy, and matplotlib
    • distributed binary size should be small

    You cannot satisfy both these requirements simultaneously. cx_Freeze is appropriate for the first, but not the second. If you can assume your end users already have Python, numpy, matplotlib installed (or can install seperately), and want to distribute your program such that the binary size be small, a wheel is more appropriate.

    0 讨论(0)
提交回复
热议问题