gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 21:53:06 24 4
gpt4 key购买 nike

比方说 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/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com