問題描述
我正在嘗試為 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.
這篇關于Kivy 1.9.0 Windows 包 KeyError: 'rthooks'的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!