python - 为什么 cx_freeze for Python 3 将一个项目打包成 8000 多个文件,而 cx_freeze for Python 2 将同一个项目打包成 25 个文件?

标签 python python-3.x python-2.7 cx-freeze

比方说 numpy_example.py是:

import numpy as np
a = np.array([1, 2, 3])
print(a)
  • 使用 Python 2.7.9,使用 cxFreeze 4.3.3 生成可执行文件,其中:
    "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,没有子文件夹:

    enter image description here
  • 使用 Python 3.7.6,使用 cxFreeze 6 生成可执行文件,使用相同的命令行命令 给出 总共 8533 个文件,总共 374 MB !

    特别是,有Lib包含该项目未使用的许多库的子文件夹:

    enter image description here

    此外,在 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/

    相关文章:

    python - 如何从列表中获取最常用的 "n"单词?

    python - 正则表达式组引用长度

    python-2.7 - 解释cv2.createbackgroundsubtractormog2()的参数

    python - 编写可重用代码

    python - 如何通过 Cloudflare 使用 Python 或 DDNS 检查公共(public) IP

    python - 循环遍历 pandas 数据框,同时使用正则表达式更改行值

    python - ipaddress.py 在有效的 ip 地址上出现错误

    python - 在 Fedora 上安装新的 Python 发行版

    python - 构建应用程序 : Is it bad form to have an app create directories on users computer for program file storage?

    python - 将 pandas 数据框分层拆分为训练、验证和测试集