比方说 numpy_example.py
是:
import numpy as np
a = np.array([1, 2, 3])
print(a)
"C:\python27\python.exe" "C:\python27\Scripts\cxfreeze" numpy_example.py
--target-dir=.\cxfreeze_x64_py2 --base-name=Win32GUI
--target-name=test.exe --exclude-modules=Tkinter,scipy,Crypto,_ssl,bz2,_yaml
--include-modules=lxml._elementpath
给出了 25 个文件(只有
.dll
、 .pyd
和 .exe
文件),总共 71 MB,没有子文件夹:特别是,有
Lib
包含该项目未使用的许多库的子文件夹:此外,在 Python 2 版本中,Numpy 被打包成 9
.pyd
文件(没有别的),而在 Python 3 版本中,它被分成许多文件和子文件夹。 问题:
cx_freeze
中发生了什么变化,导致这种效率较低的包装? 以及如何使用
cx_freeze
获得类似的包装Python 3 比 Python 2 好?
最佳答案
这似乎是答案:它是一个功能,因为 cx_freeze 5.0
:https://cx-freeze.readthedocs.io/en/latest/releasenotes.html#version-5-0-november-2016
Added support for storing packages in the file system instead of in the zip file. There are a number of packages that assume that they are found in the file system and if found in a zip file instead produce strange errors. The default is now to store packages in the file system but a method is available to place packages in the zip file if they are known to behave properly when placed there. (Issue #73)
链接:Cx_Freeze build is not including python libraries in zip file
关于python - 为什么 cx_freeze for Python 3 将一个项目打包成 8000 多个文件,而 cx_freeze for Python 2 将同一个项目打包成 25 个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62396783/