gpt4 book ai didi

python - 在 Windows 7 x64 上使用 py2exe 编译问题

转载 作者:太空狗 更新时间:2023-10-30 00:50:54 24 4
gpt4 key购买 nike

我正在使用 py2exe 将我的脚本编译成一个 exe 文件以在 Windows 上运行,但我遇到了基于我的操作系统(Window 7 x64)的错误。我正在使用 execmaker.py py2exe 在 cmd 中运行以下脚本:

from distutils.core import setup
import py2exe

includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter']
packages = []
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
'tk84.dll']

setup(
options = {"py2exe": {"compressed": 2,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 1,
"dist_dir": "dist",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
windows=['My_Script.py'] #this is the name of the script I'm compiling to exe
)

我正在编译成 exe 的实际脚本并不重要,因为当我使用 bundle_files: 3, 编译它时它工作得很好,它不捆绑任何文件并离开 ~一个文件夹中有 200 个 .pyo 文件。

那么让我们进入问题的中心:因为我在 Win 7 x64 上,所以我安装了 64 位版本的 Python 2.7.5。当我 cdexecmaker.pyMy_Script.py 文件所在的文件并在 cmd 中运行它时(execmaker .py py2exe),我收到一条错误消息,内容如下:error: bundle-files 1 is not yet supported on win64,我认为这意味着它不会捆绑文件,因为我的操作系统是 64 位的。我想这可能是因为我安装了 64 位 python 而造成的问题,但是当我卸载它时,我收到错误 DLL load failed: %1 is not a valid Win32 application.

DLL Load 错误是由于在 64 位 Windows 上运行 32 位 python 引起的。所以基本上,它不适用于 32 位或 64 位 python,因为我运行的是 64 位 Windows。是否有解决方法,或者我是否需要安装 python 和我在 32 位机器上使用的所有模块来进行编译?

编辑:我做了更多研究,但一无所获。目前,除非用更有效的方法回答这个问题,否则我想在分区上或通过 Parallels(我就是这样做的)安装 32 位操作系统就足够了。

最佳答案

我想现在对你来说已经太晚了,但对于下一个被困在这条船上的灵魂来说,在我看来,一个更有效的方法是从 oracle 免费安装 virtualbox (vb),然后安装你的 32 位操作系统它。这样您就不必对硬盘驱动器进行分区或不进行分区,并且可以像卸载任何其他程序一样毫无风险地卸载 vb。

另一种选择是尝试使用 pyinstaller。我只用它为 linux 系统制作可执行文件,但我认为你也可以在 windows 上使用它。

关于python - 在 Windows 7 x64 上使用 py2exe 编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16597867/

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