Kivy: Kivy 1.9.1, ImportError while importing kivy.app.App

Created on 4 Jan 2016  ·  26Comments  ·  Source: kivy/kivy

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

Windows

Most helpful comment

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.

All 26 comments

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

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.

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.

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, 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\widgetsvideoplayer.py does not play (http://pastebin.com/LwR1cGA7).

On Python34 64bit, everything works as expected.

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.

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.

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.

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

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.

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.

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.

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

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.

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)

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

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

C:\Python34>python sharekivy-examples\demo\showcase\main.py
[INFO ] [Logger ] Record log in C:\Users\Anubhav.kivylogskivy_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:\Python34lib\site-packageskivy\core__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Python34lib\site-packageskivy\core\window\window_sdl2.py", line 26, in
from kivy.core.window._window_sdl2 import _WindowSDL2Storage

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

i have this error please help me out

Did you install all Kivy dependencies from installation page?

I tried to install the latest kivy version on Windows 10, including sdl2 (0.1.18) and gstreamer (0.1.13), but I keep getting this error:

"C:\PycharmProjects\HelloWorld\venv\Scripts\python.exe" "C:/PycharmProjects/HelloWorld/main.py"
[INFO   ] [Logger      ] Record log in C:\.kivy\logs\kivy_18-11-20_44.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 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.
sdl2 - ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
  File "C:\PycharmProjects\HelloWorld\venv\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\PycharmProjects\HelloWorld\venv\lib\site-packages\kivy\core\text\text_sdl2.py", line 12, in <module>
    from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ModuleNotFoundError: No module named 'PIL'
  File "C:\PycharmProjects\HelloWorld\venv\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\PycharmProjects\HelloWorld\venv\lib\site-packages\kivy\core\text\text_pil.py", line 7, 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 all dependencies (successfully according to console).

C:\WINDOWS\system32>python -m pip install kivy.deps.sdl2
Collecting kivy.deps.sdl2
  Using cached https://files.pythonhosted.org/packages/93/84/a0dc274d993db6f9ebdf41eb4d55b032de005dbf47e4d54602cf83708b08/kivy.deps.sdl2-0.1.18-cp37-cp37m-win_amd64.whl
Installing collected packages: kivy.deps.sdl2
Successfully installed kivy.deps.sdl2-0.1.18

Please help me out

Install the dependencies (skip gstreamer (~120MB) if not needed, see Kivy’s dependencies):

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

I'm getting this error with PyCharm 2018.3.6 and Python Version 3.7.2 Windows10.
I have installed all dependencies also but still getting error.

sdl2 - ImportError: DLL load failed: The specified module could not be found.
File "C:\Users\Austin\AppData\Local\Programs\Python\Python37-32lib\site-packageskivy\core__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\Austin\AppData\Local\Programs\Python\Python37-32lib\site-packageskivy\core\text\text_sdl2.py", line 12, in
from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ModuleNotFoundError: No module named 'PIL'
File "C:\Users\Austin\AppData\Local\Programs\Python\Python37-32lib\site-packageskivy\core__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\Austin\AppData\Local\Programs\Python\Python37-32lib\site-packageskivy\core\text\text_pil.py", line 7, in
from PIL import Image, ImageFont, ImageDraw

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

I am also having the same issue as @VipinDubeyCB with a very similar setup.
OS: Windows10
IDE: PyCharm 2018.3.6,
Python Version 3.7.2

error msg:
[CRITICAL] [Text ] Unable to find any valuable Text provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed: The specified module could not be found.
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64lib\site-packageskivy\core__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64lib\site-packageskivy\core\text\text_sdl2.py", line 13, in
from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ModuleNotFoundError: No module named 'PIL'
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64lib\site-packageskivy\core__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64lib\site-packageskivy\core\text\text_pil.py", line 7, in
from PIL import Image, ImageFont, ImageDraw

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

For the case of using pycharm, you have to install kivy in the pycharm terminal if you are using a virtualenv, which seems to be the default setting in pycharm projects.

or you have to activate the virtual environment that your project is sourcing in your windows terminal and then install kivy

I am also having the same issue as @VipinDubeyCB with a very similar setup.
OS: Windows10
IDE: PyCharm 2018.3.6,
Python Version 3.7.2

[INFO ] [Logger ] Record log in C:\Users\Мохирбек.kivylogskivy_20-09-23_44.txt
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\Мохирбек\PycharmProjectspythonProject1venvlib\site-packageskivy__init__.py"
[INFO ] [Python ] v3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
[INFO ] [Python ] Interpreter at "C:\Users\Мохирбек\PycharmProjectspythonProject1venv\Scriptspython.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed: Не найден указанный модуль.
File "C:\Users\Мохирбек\PycharmProjectspythonProject1venvlib\site-packageskivy\core__init__.py", line 71, in core_select_lib
cls = cls()
File "C:\Users\Мохирбек\PycharmProjectspythonProject1venvlib\site-packageskivy\core\window\window_sdl2.py", line 152, in __init__
super(WindowSDL, self).__init__()
File "C:\Users\Мохирбек\PycharmProjectspythonProject1venvlib\site-packageskivy\core\window__init__.py", line 981, in __init__
self.create_window()
File "C:\Users\Мохирбек\PycharmProjectspythonProject1venvlib\site-packageskivy\core\window\window_sdl2.py", line 290, in create_window
self.get_gl_backend_name())
File "C:\Users\Мохирбек\PycharmProjectspythonProject1venvlib\site-packageskivy\core\window__init__.py", line 1220, in get_gl_backend_name
ignored=self.gl_backends_ignored)
File "kivy\graphics\cgl.pyx", line 56, in kivy.graphics.cgl.cgl_get_backend_name
File "kivy\graphics\cgl.pyx", line 69, in kivy.graphics.cgl.cgl_get_backend_name
File "C:\Users\Мохирбек\AppData\Local\Programs\Python\Python37-32lib\importlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 670, in _load_unlocked
File "", line 583, in module_from_spec
File "", line 1043, in create_module
File "", line 219, in _call_with_frames_removed

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

Process finished with exit code 1

Was this page helpful?
0 / 5 - 0 ratings