在 Windows XP 下运行 Python 二进制文件 [英] Run Python binaries under Windows XP

查看:64
本文介绍了在 Windows XP 下运行 Python 二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 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')

解决方案

最终我发现了与这个问题相关的核心问题:

<块引用><块引用>

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:

这篇关于在 Windows XP 下运行 Python 二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆