community icon indicating copy to clipboard operation
community copied to clipboard

Kivy 1.9.1, ImportError while importing kivy.app.App

Open pythonic64 opened this issue 10 years ago • 26 comments

Installed fresh Python2.7.10, Kivy1.9.1 (following instructions from kivy.org website) on Windows7 64bit. I'm getting an ImportError when I run this code:

from kivy.app import App
from kivy.uix.button import Button


class ButtonApp(App):

    def build(self):
        return Button(text='TEST')


ButtonApp().run()

Console output:

E:\Python27\python.exe E:/workspace/TEST/test_kivy_1.9.1/main.py
[INFO              ] [Logger      ] Record log in C:\Users\Skerleton\.kivy\logs\kivy_16-01-04_38.txt
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
[INFO              ] [Factory     ] 179 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=None
 Traceback (most recent call last):
   File "E:/workspace/TEST/test_kivy_1.9.1/main.py", line 1, in <module>
     from kivy.app import App
   File "E:\Python27\lib\site-packages\kivy\app.py", line 327, in <module>
     from kivy.uix.widget import Widget
   File "E:\Python27\lib\site-packages\kivy\uix\widget.py", line 219, in <module>
     from kivy.graphics import (
   File "E:\Python27\lib\site-packages\kivy\graphics\__init__.py", line 89, in <module>
     from kivy.graphics.instructions import Callback, Canvas, CanvasBase, \
 ImportError: DLL load failed: The specified module could not be found.

Process finished with exit code 1

Kivy installed without issues, except for Gstreamer. This error is reported by another developer on kivy google group

pythonic64 avatar Jan 04 '16 16:01 pythonic64

This kind of problem is hard to debug here. It'd be easier if you joined us on IRC at #kivy.

matham avatar Jan 04 '16 21:01 matham

The gstreamer problem has been fixed. I also updated all the dependencies so I'd suggest you download them again with python -m pip install --upgrade docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew kivy.deps.gstreamer --extra-index-url https://kivy.org/downloads/packages/simple/ as this may fix your problem. Let us know.

matham avatar Jan 05 '16 02:01 matham

After I upgraded the dependencies new issue occurs:

E:\Python27\python.exe E:/workspace/TEST/test_kivy_1.9.1/main.py
[INFO              ] [Logger      ] Record log in C:\Users\Skerleton\.kivy\logs\kivy_16-01-05_4.txt
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
[INFO              ] [Factory     ] 179 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=None
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout=60
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout=None
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeout=60
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600
[DEBUG             ] [Text        ] Ignored <sdl2> (import error)
[DEBUG             ] [Text        ] Ignored <pil> (import error)
[CRITICAL          ] [Text        ] Unable to find any valuable Text provider at all!
sdl2 - ImportError: DLL load failed: The specified procedure could not be found.
  File "E:\Python27\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "E:\Python27\lib\site-packages\kivy\core\text\text_sdl2.py", line 12, in <module>
    from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ImportError: No module named PIL
  File "E:\Python27\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "E:\Python27\lib\site-packages\kivy\core\text\text_pil.py", line 8, in <module>
    from PIL import Image, ImageFont, ImageDraw

[CRITICAL          ] [App         ] Unable to get a Text provider, abort.

Process finished with exit code 1

I installed pillow to so that kivy can use it as text provider but then I get Exception:

E:\Python27\python.exe E:/workspace/TEST/test_kivy_1.9.1/main.py
[INFO              ] [Logger      ] Record log in C:\Users\Skerleton\.kivy\logs\kivy_16-01-05_9.txt
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
[INFO              ] [Factory     ] 179 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=None
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout=60
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout=None
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeout=60
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600
[DEBUG             ] [Text        ] Ignored <sdl2> (import error)
[INFO              ] [Text        ] Provider: pil(['text_sdl2'] ignored)
[DEBUG             ] [App         ] Loading kv <E:/workspace/TEST/test_kivy_1.9.1\button.kv>
[DEBUG             ] [App         ] kv <E:/workspace/TEST/test_kivy_1.9.1\button.kv> not found
[INFO              ] [OSC         ] using <thread> for socket
[INFO              ] [Window      ] Provider: sdl2
[INFO              ] [GL          ] GLEW initialization succeeded
[INFO              ] [GL          ] OpenGL version <4.5.0 NVIDIA 347.88>
[INFO              ] [GL          ] OpenGL vendor <NVIDIA Corporation>
[INFO              ] [GL          ] OpenGL renderer <GeForce GTX 560 SE/PCIe/SSE2>
[INFO              ] [GL          ] OpenGL parsed version: 4, 5
[INFO              ] [GL          ] Shading version <4.50 NVIDIA>
[INFO              ] [GL          ] Texture max size <16384>
[INFO              ] [GL          ] Texture max units <32>
[DEBUG             ] [Shader      ] Fragment compiled successfully
[DEBUG             ] [Shader      ] Vertex compiled successfully
[DEBUG             ] [ImageSDL2   ] Load <E:\Python27\lib\site-packages\kivy\data\glsl\default.png>
[INFO              ] [Window      ] auto add sdl2 input provider
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
[DEBUG             ] [Resource    ] add <C:\Windows\Fonts> in path list
[DEBUG             ] [Resource    ] add <E:\Python27\lib\site-packages\kivy\data\fonts> in path list
[DEBUG             ] [Base        ] Create provider from mouse,disable_multitouch
[DEBUG             ] [Base        ] Create provider from wm_touch
[DEBUG             ] [Base        ] Create provider from wm_pen
[INFO              ] [Base        ] Start application main loop
[INFO              ] [GL          ] NPOT texture support is available
[DEBUG             ] [Atlas       ] Load <E:\Python27\lib\site-packages\kivy\data\..\data\images\defaulttheme.atlas>
[DEBUG             ] [Atlas       ] Need to load 1 images
[DEBUG             ] [Atlas       ] Load <E:\Python27\lib\site-packages\kivy\data\..\data\images\defaulttheme-0.png>
[DEBUG             ] [ImageSDL2   ] Load <E:\Python27\lib\site-packages\kivy\data\..\data\images\defaulttheme-0.png>
 Exception Exception: Exception('tostring() has been removed. Please call tobytes() instead.',) in 'kivy.graphics.instructions.RenderContext.set_texture' ignored

And button text isn't displayed correctly: screenshot_20

I joined IRC #kivy, nickname "pythonic64", if you have questions.

pythonic64 avatar Jan 05 '16 14:01 pythonic64

tuve el mismo problema corriendo en Windows, lo solucione instalando una version anterior del paquete SDL2 probandolos de aca https://kivy.org/downloads/appveyor/deps/sdl2/

SamZapata avatar Jan 13 '16 07:01 SamZapata

@SamZapata, SDL2 is not the issue anymore for me, Gstreamer is. Installing latest gstreamer (kivy.deps.gstreamer-0.1.5) causes the above text provider error on Python27 and Python34 32bit. Also, Gstreamer installation doesn't generate "registry.bin" file in folder: Python27\share\gstreamer.

@matham found that this error occurs because of conflicts between SDL2 and Gstreamer dll files. Removing "libfreetype-6.dll" from gstreamer\bin solved the text issue, but video in ..\kivy-examples\widgets\videoplayer.py does not play (http://pastebin.com/LwR1cGA7).

On Python34 64bit, everything works as expected.

pythonic64 avatar Jan 13 '16 14:01 pythonic64

I have uploaded a new gstreamer to https://drive.google.com/drive/folders/0B1_HB9J8mZepNzZ5aW91Q0tJU2s. However, I didn't test this yet as I don't currently have a clean system to try on. But that version may play nicer with the current sdl2.

matham avatar Jan 16 '16 20:01 matham

Installed new Gstreamer wheel kivy.deps.gstreamer-0.1.6-cp27-none-win32. Same error as before:

e:\Python27\share\kivy-examples\widgets>python label_mipmap.py
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)]
[INFO              ] [Factory     ] 179 symbols loaded
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[CRITICAL          ] [Text        ] Unable to find any valuable Text provider at all!
sdl2 - ImportError: DLL load failed: The specified procedure could not be found.
  File "E:\Python27\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "E:\Python27\lib\site-packages\kivy\core\text\text_sdl2.py", line 12, in <module>
    from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ImportError: No module named PIL
  File "E:\Python27\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "E:\Python27\lib\site-packages\kivy\core\text\text_pil.py", line 8, in <module>
    from PIL import Image, ImageFont, ImageDraw

[CRITICAL          ] [App         ] Unable to get a Text provider, abort.

pythonic64 avatar Jan 16 '16 21:01 pythonic64

Hmm, ok. I hoped updating from a 2013 version would fix it. I'm not sure how to permenantly solve this. We cannot just delete the "bad" dll from gstreamer and rely on the sdl2 version of it because what if sdl2 is not installed? Then gstreamer won't work anymore since that dll would be missing.

matham avatar Jan 16 '16 21:01 matham

How about releasing version of gstreamer to be used with sdl2 installation on Python 32bit? Then users can choose which version to install.

pythonic64 avatar Jan 16 '16 21:01 pythonic64

You cannot upload multiple versions of gstreamer and have pip find it. I think you can only do one version. So that version will have to work with and without sdl2. I'll have to investigate a little deeper for the exact issue because when I tested I think gst worked with the sdl2 dll. But you said it didn't work for you. So I'll have to test on a clean system to be sure.

matham avatar Jan 16 '16 22:01 matham

I have traced this down and I believe it's due to an issue with the sdl2_ttf dlls. I opened an issue for it with sdl2: https://bugzilla.libsdl.org/show_bug.cgi?id=3241.

matham avatar Jan 17 '16 00:01 matham

I ended up building sdl2_ttf myself on msys2, which I believe should fix the issue until sdl2 itself releases a update. Try it with pip install --upgrade kivy.deps.sdl2.

matham avatar Jan 18 '16 03:01 matham

[INFO ] [Text ] Provider: pil(['text_sdl2'] ignored)

dessant avatar Jan 18 '16 07:01 dessant

I don't have gstreamer installed at all, but it still falls back to pil, same with kivy.deps.sdl2==0.1.8 kivy.deps.sdl2_dev==0.1.8.

dessant avatar Jan 18 '16 07:01 dessant

With kivy.deps.sdl2==0.1.11 and kivy.deps.gstreamer==0.1.6 sdl2 gets selected as text provider, but gstreamer doesn't as video provider. Same with kivy.deps.gstreamer==0.1.5.

[INFO ] [Video ] Provider: null(['video_pygst', 'video_ffmpeg', 'video_ffpyplayer', 'video_pyglet'] ignored)

pythonic64 avatar Jan 18 '16 13:01 pythonic64

For me both gstreamer and sdl2 text work fine. Dessant can you try with the latest packages?

matham avatar Jan 18 '16 18:01 matham

I reinstalled Python and Kivy with kivy.deps.sdl2==0.1.12, kivy.deps.gstreamer==0.1.6. It works!

e:\Python27>python share\kivy-examples\widgets\videoplayer.py
[INFO              ] [Logger      ] Record log in C:\Users\Skerleton\.kivy\logs\kivy_16-01-18_60.txt
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)]
[INFO              ] [Factory     ] 179 symbols loaded
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO              ] [Text        ] Provider: sdl2
[INFO              ] [VideoGstplayer] Using Gstreamer 1.7.1.0
[INFO              ] [Video       ] Provider: gstplayer
[INFO              ] [OSC         ] using <thread> for socket
[INFO              ] [Window      ] Provider: sdl2
[INFO              ] [GL          ] GLEW initialization succeeded
[INFO              ] [GL          ] OpenGL version <4.5.0 NVIDIA 347.88>
[INFO              ] [GL          ] OpenGL vendor <NVIDIA Corporation>
[INFO              ] [GL          ] OpenGL renderer <GeForce GTX 560 SE/PCIe/SSE2>
[INFO              ] [GL          ] OpenGL parsed version: 4, 5
[INFO              ] [GL          ] Shading version <4.50 NVIDIA>
[INFO              ] [GL          ] Texture max size <16384>
[INFO              ] [GL          ] Texture max units <32>
[INFO              ] [Window      ] auto add sdl2 input provider
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO              ] [GL          ] NPOT texture support is available
[INFO              ] [Base        ] Start application main loop

pythonic64 avatar Jan 18 '16 21:01 pythonic64

C:\Python34>python share\kivy-examples\demo\showcase\main.py [INFO ] [Logger ] Record log in C:\Users\Anubhav.kivy\logs\kivy_18-03-09_54.txt [INFO ] [Kivy ] v1.10.0 [INFO ] [Python ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)] [INFO ] [Factory ] 194 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored) [CRITICAL] [Window ] Unable to find any valuable Window provider. sdl2 - ImportError: DLL load failed: The specified module could not be found. File "C:\Python34\lib\site-packages\kivy\core_init_.py", line 59, in core_select_lib fromlist=[modulename], level=0) File "C:\Python34\lib\site-packages\kivy\core\window\window_sdl2.py", line 26, in from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App ] Unable to get a Window, abort.

Alferdize avatar Mar 09 '18 16:03 Alferdize

i have this error please help me out

Alferdize avatar Mar 09 '18 16:03 Alferdize

Did you install all Kivy dependencies from installation page?

pythonic64 avatar Mar 09 '18 16:03 pythonic64