【问题标题】:python cx_Freeze egg problempython cx_Freeze Egg问题
【发布时间】:2011-02-07 16:27:28
【问题描述】:

我正在尝试从 python 脚本(使用大量鸡蛋)构建可执行文件(用于 32 位 windows xp)

我考虑过 py2exe(0.6.9)、PyInstaller (1.4) 和 cx_Freeze (4.1.2)

py2exe doesnt like eggs for breakfast

PyInstaller doesnt like python 2.6 for lunch)

所以我选择了 cx_Freeze (supposed to support eggs seamlessly since 4.0)。但由于某种原因它没有。

为了识别鸡蛋中的文件,我传递了哪些参数?

【问题讨论】:

    标签: python py2exe pyinstaller cx-freeze


    【解决方案1】:

    您可以尝试在您提供的页面中链接的 PyInstaller 的 2.6 分支。

    【讨论】:

      【解决方案2】:

      在你的源目录中解压你的eggs模块,并在你的setup.py中添加package: [dependencies,]。 遵循py2Exe Docs 中的 py2exe 文档,我执行了您在源代码中运行最多的脚本:python unpackEgg.py eggsmodule

          import os
          import pkg_resources
          import sys
          from setuptools.archive_util import unpack_archive
      
          def unpackEgg(modulo):
              eggs = pkg_resources.require(modulo)
              for egg in eggs:
                  if os.path.isdir(egg.location):
                      sys.path.insert(0, egg.location)
                      continue
                  unpack_archive(egg.location, ".")
              eggpacks = set()
              eggspth = open("./eggs.pth", "w")
              for egg in eggs:
                  print egg
                  eggspth.write(os.path.basename(egg.location))
                  eggspth.write("\n")
                  eggpacks.update(egg.get_metadata_lines("top_level.txt"))
              eggspth.close()
      
              eggpacks.clear()
      
      
          if __name__ == '__main__':
          unpackEgg(sys.argv[1])
      

      【讨论】:

      • 太棒了!这也适用于 cx freeze 和 python 3.3,只需将 print egg 更改为 print(egg)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-22
      • 2018-06-15
      • 1970-01-01
      • 1970-01-01
      • 2012-09-25
      • 1970-01-01
      • 2018-09-21
      相关资源
      最近更新 更多