在 Windows XP 下运行 Python 二进制文件 [英] Run Python binaries under Windows XP
问题描述
我将 PySide 应用程序编译为 x32 和 x64 模式,它可以在 Windows 7+ 下运行.但是我发现该应用程序在 Windows XP 下无法启动.
我应该在规范文件中额外使用一些技巧吗?
当前 PyInstaller 脚本显示在 app.spec 文件中:
<块引用>pyinstaller src/app.spec
# -*- 模式:python -*-导入操作系统进口平台从 PySide 导入 QtCore一个文件 = 错误控制台 = 错误platform_name = platform.system().lower()app_name = {'linux': 'app','达尔文':'应用','windows': 'app.exe'}[platform_name]# 包括图像格式插件plugins=os.path.join(os.path.dirname(QtCore.__file__), "plugins\\imageformats")static_files = Tree(plugins, 'plugins\\imageformats')static_files += [('app.ico', 'src\\app.ico', 'DATA')]# 分析来源a = Analysis(['src\\app.py'],hiddenimports=['pkg_resources'],钩子路径=无,runtime_hooks=无)pyz = PYZ(a.pure)如果一个文件:exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, name=app_name,debug=False, strip=None, upx=True, console=console, icon='src/app.ico', version='src/app.ver')别的:exe = EXE(pyz, a.scripts, exclude_binaries=True, name=app_name, debug=False,strip=None, upx=True, console=console, icon='src/app.ico', version='src/app.ver')coll = COLLECT(exe, a.binaries, static_files, a.zipfiles, a.datas, strip=None, upx=True, name='app')
最终我发现了与这个问题相关的核心问题:
<块引用><块引用>不需要在源代码处使用
print()
,这里有更多详细信息 - PyInstaller 打包的应用程序在控制台模式下工作正常,在窗口模式下崩溃在那之后,我发现了
import requests
的问题和这里的解决方案 - http://flashmaestro.blogspot.com/2015/04/pyinstaller-solution-about.html
I compiled my PySide application to both x32 and x64 mode and it's work under Windows 7+. However I found that the application can't start under Windows XP.
Should I use some tricks in spec-file additionally?
Current PyInstaller script shown below in app.spec file:
pyinstaller src/app.spec
# -*- mode: python -*-
import os
import platform
from PySide import QtCore
onefile = False
console = False
platform_name = platform.system().lower()
app_name = {'linux': 'app',
'darwin': 'app',
'windows': 'app.exe'}[platform_name]
# Include imageformats plugins
plugins=os.path.join(os.path.dirname(QtCore.__file__), "plugins\\imageformats")
static_files = Tree(plugins, 'plugins\\imageformats')
static_files += [('app.ico', 'src\\app.ico', 'DATA')]
# Analyze sources
a = Analysis(['src\\app.py'],
hiddenimports=['pkg_resources'],
hookspath=None,
runtime_hooks=None)
pyz = PYZ(a.pure)
if onefile:
exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, name=app_name,
debug=False, strip=None, upx=True, console=console, icon='src/app.ico', version='src/app.ver')
else:
exe = EXE(pyz, a.scripts, exclude_binaries=True, name=app_name, debug=False,
strip=None, upx=True, console=console, icon='src/app.ico', version='src/app.ver')
coll = COLLECT(exe, a.binaries, static_files, a.zipfiles, a.datas, strip=None, upx=True, name='app')
Eventually, I found the core problems related to this issue:
Don't need to use
print()
at the sources, more detail here - PyInstaller packaged application works fine in Console mode, crashes in Window modeAfter that I catched issue with
import requests
and solution here - http://flashmaestro.blogspot.com/2015/04/pyinstaller-solution-about.html
这篇关于在 Windows XP 下运行 Python 二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!