2

I am starting to use kivy for my game, so while following some tutorials online, the python shell returns these errors.

[INFO] [Logger] Record log in C:\Users\...\.kivy\logs\kivy_18-10-23_8.txt
[INFO] [Kivy] v1.10.1
[INFO] [Python] v3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)]
[INFO] [Factory] 194 symbols loaded
[INFO] [Image] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO] [Window] Provider: sdl2
[CRITICAL] [Window] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    cls = cls()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
    super(WindowSDL, self).__init__()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\core\window\__init__.py", line 968, in __init__
    self.create_window()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 272, in create_window
    self.fullscreen, resizable, state)
  File "kivy\core\window\_window_sdl2.pyx", line 125, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
  File "kivy\graphics\cgl.pyx", line 52, in kivy.graphics.cgl.cgl_get_backend_name
  File "kivy\graphics\cgl.pyx", line 60, in kivy.graphics.cgl.cgl_get_backend_name
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  [CRITICAL] [App] Unable to get a Window, abort.

I have installed docutils, pygments, pypiwin32, kivy.deps.sdl2, kivy.deps.glew and Cython. I am using kivy 1.10.1 and python 3.7.0 The code that I was following is this:

from kivy.app import App
from kivy.uix.widget import Widget


class PongGame(Widget):
    pass


class PongApp(App):
    def build(self):
        return PongGame()


if __name__ == '__main__':
    PongApp().run()

Am I having errors with my modules or something wrong with the code?

SoInstant
  • 49
  • 9

2 Answers2

3

Looking at Kivy's install Docs I was able to repeat your problem from a fresh install, where I installed kivy without first doing the dependancies.

I fixed it by running these in order:

python -m pip install --upgrade pip wheel setuptools

python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew

python -m pip install kivy.deps.gstreamer

python -m pip install kivy

As you're running Python 3 you'll also need:

python -m pip install kivy.deps.angle

Note: If you're running an environment with python2 and python3 - make sure you replace pip with pip3

Dan O'Boyle
  • 3,676
  • 5
  • 28
  • 44
  • Yes, I am only running python 3.x. I was not able to install kivy.deps.gstreamer as it would post an error everytime it reached about 20%, and since it is needed only for video streaming, I assumed that it was not needed. – SoInstant Oct 23 '18 at 13:39
  • 1
    Exploring that error may resolve your problem. Seems like a dependency issue for sure - I'd run through the dependancy steps again anyway, ensuring you use -m. Good luck! – Dan O'Boyle Oct 23 '18 at 13:43
  • 2
    Note for future viewers: Uninstall kivy before installing the other packages – SoInstant Oct 23 '18 at 13:49
  • What does -m do? – SoInstant Oct 23 '18 at 13:53
  • The -m helps ensure that the version of python executing pip references the pip module related to that python version: https://docs.python.org/3/using/cmdline.html#cmdoption-m – Dan O'Boyle Oct 23 '18 at 14:23
2

The code runs fine for me. It looks likely that you are missing some dependencies.

You have listed all the required dependencies I can see, but perhaps they have not been installed properly:

Looking at this answer or the one below it for some suggestions:

https://stackoverflow.com/a/44220712/9742036

Installing using pip worked for some users:

python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew; python -m pip install kivy.deps.gstreamer

Otherwise they needed to uninstall and re-install or use conda.

Andrew McDowell
  • 2,860
  • 1
  • 17
  • 31