Kivy 1.9.0 Windows 包 KeyError: 'rthooks'
问题描述
我正在尝试为 Windows 打包我的 Kivy 应用程序,但遇到了一些问题.按照 kivy docs 中的说明,我创建并编辑了规范文件.我既不使用 pygame 也不使用 SDL2(我的意思是我不直接导入它们来运行我的程序),但在 Kivy 日志中我看到 pygame 仍然提供我的窗口:
I'm trying to package my Kivy app for Windows, but I'm having some issues. Following the instructions in the kivy docs, I created and edited the spec file. I don't use neither pygame nor SDL2 (I mean I don't import them directly to run my program), but in the Kivy log I see pygame still provides my window:
[INFO ] [Text ] Provider: pygame
[INFO ] [Window ] Provider: pygame
我不明白为什么,因为我使用的是 kivy 1.9.0.
I don't understand why, since I'm using kivy 1.9.0.
也就是说,我在构建规范时遇到了这个问题:
Said that, I'm having this problem when building the spec:
(...)
202 WARNING: stderr: File "C:Program FilesPython Kivy-1.9.0-py3.4-win32-x86kivy34kivy oolspackagingpyinstaller_hooks\__init__.py", line 13, in install_hooks
sym['rthooks']['kivy'] = [join(curdir, 'rt-hook-kivy.py')]
202 WARNING: stderr: sym['rthooks']['kivy'] = [join(curdir, 'rt-hook-kivy.py')]
KeyError: 'rthooks'
202 WARNING: stderr: KeyError: 'rthooks'
我对编辑规范有点困惑(我需要导入 pygame/SDL2?),这可能是我的问题.我正在使用 Windows 7 x86、Python 3.4.3 和 Kivy 1.9.0.任何帮助表示赞赏.
I'm a little confused about editing the spec (I need to import pygame/SDL2?), and that's probably my problem. I'm using Windows 7 x86, Python 3.4.3 and Kivy 1.9.0. Any help is appreciated.
解决方案
2015 年 10 月 1 日更新:
事实证明这是一个错误.截至 2015 年 9 月 24 日的最新进展Kivy 版本应该没有这个问题.
It turns out this is a bug. As of 24 September 2015 the latest development version of Kivy should be free of this issue.
从源代码在 Windows 上安装 Kivy,不使用 Christoph Gohlke 的预编译轮子,虽然是另一个难以破解的难题,所以在实践中,如果你真的渴望 Python 3.x 兼容性,可能最简单的方法是等到 Kivy 团队发布 1.9.0 之后的另一个版本,然后 Gohlke 的脚本生成简单的- 安装二进制文件.
Installing Kivy on Windows from source code, without the use of Christoph Gohlke's pre-compiled wheels, is another tough nut to crack though, so in practice if you truly crave Python 3.x compatibility it may be easiest to wait until the Kivy team issues another release past 1.9.0, and Gohlke's script to generate the easy-to-install binary.
我已经部分解决了这个问题:
I've partially troubleshooted this:
您引用的 kivy docs 提到将以下三行添加到顶部.spec
文件:
The kivy docs you reference mention adding the following three lines to the top of the .spec
file:
from kivy.tools.packaging.pyinstaller_hooks import install_hooks
import os
install_hooks(globals())
错误发生在 install_hooks(globals())
中,定义在 Libsite-packageskivy oolspackagingpyinstaller_hooks\__init__.py
:
The error is happening in install_hooks(globals())
, which is defined at Libsite-packageskivy oolspackagingpyinstaller_hooks\__init__.py
:
from os.path import dirname, join
from functools import partial
curdir = dirname(__file__)
def install_hooks(sym, hookspath=None):
_hookspath = [curdir]
if hookspath is not None:
_hookspath += hookspath
sym['rthooks']['kivy'] = [join(curdir, 'rt-hook-kivy.py')]
sym['Analysis'] = partial(sym['Analysis'], hookspath=_hookspath)
但倒数第二行导致消息:WARNING: stderr: KeyError: 'rthooks'
.
But the second last line is causing the message: WARNING: stderr: KeyError: 'rthooks'
.
所以看起来它期望一个变量 rthooks
在全局命名空间中,但事实并非如此.
So it looks like it's expecting a variable rthooks
to be in the global namespace, but it's not.
我不确定下一步该做什么.
I'm not sure what to do next.
相关文章