【问题标题】:Missing Dependencies when generating executable using py2exe使用 py2exe 生成可执行文件时缺少依赖项
【发布时间】:2015-09-03 15:56:51
【问题描述】:

我在从 python 和第三方“DLL”生成可执行文件时遇到问题。我正在使用 py2exe。最后我得到一个缺少模块的错误,但该模块是在 DLL 中定义的。

我的 Setup.py 看起来像这样:

from distutils.core import setup
import py2exe, sys, os
import glob

setup(
    options = {'py2exe':{ "includes":["clr","openpyxl"]}},
    data_files=[('.', glob.glob('XLX2DBC.dll'))],
    windows = [{'script': "CANDBCGenerator.py"}],
    zipfile = None

)

这有什么问题?

【问题讨论】:

  • 你得到的回溯是什么?
  • 复制 C:\Python27\DLLs\tcl85.dll -> C:\Users\t7245mh\Desktop\exp\files\dist *** 复制数据文件 *** 复制 XLX2DBC.dll -> C:\Users\t7245mh\Desktop\exp\files\dist\。复制 C:\Python27\lib\site-packages\py2exe\run_w.exe -> C:\Users\t7245mh\Deskt op\exp\files\dist\CANDBCGenerator.exe 以下模块似乎缺少 ['DBVector_DBC', 'ElementC14N', 'Image', 'PIL', '_scproxy', '_sysconfigdata', 'l xml.etree'] *** 二进制依赖 *** 您的可执行文件也依赖于这些不包括在内的 dll,您可能需要也可能不需要分发它们。
  • 那是 py2exe 的输出。运行 .exe 时的回溯会很有趣。
  • 运行Exe时,出现错误窗口“xxx.exe已停止工作” 一个问题导致程序停止正常工作。请关闭程序。和“关闭程序”按钮。我没有得到跟踪。

标签: python-2.7 dll clr py2exe openpyxl


【解决方案1】:

有类似的问题,所以我切换到 pyinstaller。您可以使用 pip install pyinstaller 安装它。比你使用: python pyinstaller.py --onefile your_main_file.py --onefile 选项会将依赖项打包到 EXE 中。 这是关于 pyinstaller 的有用帖子: http://irwinkwan.com/2013/04/29/python-executables-pyinstaller-and-a-48-hour-game-design-compo/

【讨论】:

    【解决方案2】:

    停止工作错误可能是由于未找到 MS 运行时。以下 wiki 展示了如何将它们包含在 py2exe 中。

    http://wiki.wxpython.org/py2exe-python26

    Python 2.7 使用版本 9.0.30729.1 的 MS 运行时,您应该从 Python 文件夹中获取它们。

    【讨论】:

    • 我在跟踪中收到以下错误:Traceback(最近一次调用最后一次):文件“CANDBCGenerator.py”,第 2 行,在 文件“zipextimporter.pyo”,第 98 行,在 load_module ImportError : MemoryLoadLibrary 加载 clr.pyd 失败
    • "includes" 是用于文件的,我建议你改用"packages"。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-24
    • 2010-09-11
    相关资源
    最近更新 更多