Ian*_*ane 5 python 64-bit compilation py2exe
我正在使用py2exe将我的脚本编译成一个在Windows上运行的exe文件,但是我的操作系统是基于我的操作系统,即Window 7 x64.我使用以下命令在cmd中运行以下脚本execmaker.py py2exe:
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
Run Code Online (Sandbox Code Playgroud)
)
我编译成exe实际脚本并不重要,因为它工作时,我用它编译完全没问题bundle_files: 3,不捆绑任何一个文件夹中的文件和叶〜200个.pyo文件.
让我们来看看问题的中心:当我在Win 7 x64上时,我安装了64位版本的Python 2.7.5.当我cd到那里的文件execmaker.py和My_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加载错误是由64位Windows上运行32位python引起的.所以基本上,它不适用于32位或64位python,因为我正在运行64位Windows.有没有解决方法,或者我是否需要安装python和我在32位机器上使用的所有模块来进行编译?
感谢您的帮助,并通过这个非常长的问题与我联系.
编辑 - 解决方案:我做了更多研究,没有提出任何建议.现在,除非用更有效的方法回答这个问题,我想在分区上或通过Parallels安装32位操作系统(我就是这样做的)就足够了.
我想现在对您来说为时已晚,但对于下一个困在这条船上的灵魂,在我看来,更有效的方法是从 oracle 免费安装 virtualbox (vb),然后在其上安装您的 32 位操作系统。这样你就不必对你的硬盘进行分区或其他什么,你可以像任何其他程序一样毫无风险地卸载 vb。
另一种选择是尝试使用 pyinstaller。我只用它来为 linux 系统制作可执行文件,但我认为你也可以在 windows 上使用它。