Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kivy 1.9.0 Windows package KeyError: 'rthooks'

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

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 Files\Python Kivy-1.9.0-py3.4-win32-x86\kivy34\kivy\tools\packaging\pyinstaller_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'

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.

like image 860
Hisu Avatar asked Jun 26 '15 22:06

Hisu


1 Answers

Update, 1 October 2015:

It turns out this is a bug. As of 24 September 2015 the latest development version of Kivy should be free of this issue.

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:

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())

The error is happening in install_hooks(globals()), which is defined at \Lib\site-packages\kivy\tools\packaging\pyinstaller_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)

But the second last line is causing the message: WARNING: stderr: KeyError: '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.

like image 144
Michael Currie Avatar answered Sep 20 '22 11:09

Michael Currie