用 py2exe 制作的可执行文件不能在 windows xp 32bit 上运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6378673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
executable made with py2exe doesn't run on windows xp 32bit
提问by Razor Storm
I created an executable with py2exe on a 64bit windows 7 machine, and distributed the program.
我在 64 位 Windows 7 机器上用 py2exe 创建了一个可执行文件,并分发了该程序。
On a windows xp 32bit machine the program refuses to run exhibiting the following behavior:
在 windows xp 32 位机器上,程序拒绝运行,表现出以下行为:
a popup window says: program.exe is not a valid win32 application.
The command prompt window says "access denied"
弹出窗口显示:program.exe 不是有效的 win32 应用程序。
命令提示符窗口显示“拒绝访问”
I checked for permissions and the user has full control and complete ownership of the file and its parent directories. So that can't be the issue.
我检查了权限,用户拥有文件及其父目录的完全控制权和所有权。所以这不可能是问题。
The only feasible possibility I can image is an OS/architectural incompatibility. How should I fix this?
我能想象的唯一可行的可能性是操作系统/架构不兼容。我应该如何解决这个问题?
My setup.py file used to generate the executable:
我的 setup.py 文件用于生成可执行文件:
from distutils.core import setup
import py2exe
setup(console=['xerxes2excel.py'])
I ran the following to generate the exe:
我运行以下命令来生成 exe:
python setup.py py2exe
回答by bwawok
I think you just need to install 32-bit python and 32-bit py2exe on your machine.... see Can 64-bit python create 32-bit Windows executables
我认为你只需要在你的机器上安装 32 位 python 和 32 位 py2exe ......请参阅Can 64-bit python create 32-bit Windows executables
回答by Gagou
A common problem when you generate executable on Windows 7 and deploy on Windows XP.
在 Windows 7 上生成可执行文件并在 Windows XP 上部署时的常见问题。
According with the py2exe tutorial, you need include the MVC DLL. But the tutorial is old and the script given search only in one directory. Before, the directory contained all DLL and the manifest, but nowadays it contains only the DLL. You need to specify another directory for the manifest file. If you don't do that, you will have this kind of error:
根据 py2exe 教程,您需要包含 MVC DLL。但是教程很旧,脚本只在一个目录中搜索。以前,该目录包含所有 DLL 和清单,但现在它只包含 DLL。您需要为清单文件指定另一个目录。如果你不这样做,你会遇到这样的错误:
this application has failed to start because the application configuration is incorrect
If you are on Windows 7 64 bits, you need the Microsoft Visual C runtime DLL. Don't forget the manifest that isn't in the same directory in Windows 7. You need to adapt the script like this:
如果您使用的是 Windows 7 64 位,则需要 Microsoft Visual C 运行时 DLL。不要忘记不在 Windows 7 中的同一目录中的清单。您需要像这样调整脚本:
data_files = [("VC90", glob(r'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\*.*')),
("VC90", glob(r'C:\Windows\winsxs\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest'))
]
setup(
data_files=data_files,
console = [{'script': "C:\test\my_program.py"}],
zipfile = None,
)
Now you can deploy the "dist" directory that contains all files and dependencies.
现在您可以部署包含所有文件和依赖项的“dist”目录。