Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kivy sdl2 DLL Load failed #5677

Closed
JaimieDodd opened this issue Mar 26, 2018 · 33 comments
Closed

Kivy sdl2 DLL Load failed #5677

JaimieDodd opened this issue Mar 26, 2018 · 33 comments
Assignees
Labels

Comments

@JaimieDodd
Copy link

JaimieDodd commented Mar 26, 2018

  • Python: 3.6.4
  • OS: Windows 10
  • Kivy: 1.10.0
  • Kivy installation method:
    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.deps.angle
    python -m pip install kivy
    python -m pip install kivy_examples
    python -m pip install Pillow
    python -m pip install cython
    python -m pip install PyEnchant

Description

Hi, I am trying to run the example code from the install Kivy. The following is the error I receive back. Any help would be great. I have tried looking at previous enquiries about similar problems, but nothing suggested on them has worked so far.

[INFO   ] [Logger      ] Record log in C:\Users\DoddJ\.kivy\logs\kivy_18-03-26_52.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: pil(['text_sdl2'] ignored)
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 26, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App         ] Unable to get a Window, abort.
 Exception ignored in: 'kivy.properties.dpi2px'
 Traceback (most recent call last):
   File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\utils.py", line 496, in __get__
     retval = self.func(inst)
   File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\metrics.py", line 174, in dpi
     EventLoop.ensure_window()
   File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\base.py", line 127, in ensure_window
     sys.exit(1)
 SystemExit: 1
[CRITICAL] [App         ] Unable to get a Window, abort.

Code and Logs

Code that I am trying to run:

import kivy
kivy.require('1.10.0') # replace with your current kivy version !

from kivy.app import App
from kivy.uix.label import Label


class MyApp(App):

    def build(self):
        return Label(text='Hello world')


if __name__ == '__main__':
    MyApp().run()
@dolang
Copy link
Contributor

dolang commented Mar 26, 2018

what does this say on your system (PowerShell):

python -m pip freeze | select-string cython

@JaimieDodd
Copy link
Author

JaimieDodd commented Mar 26, 2018

@dolang it says
'select-string' is not recognized as an internal or external command,
operable program or batch file.

@dolang
Copy link
Contributor

dolang commented Mar 26, 2018

yeah, sorry that wasn't clear. You need to execute that in PowerShell. It's the replacement for the DOS prompt.

Use Win + x then select it, or type powershell at the command prompt. You will have PS as the first 2 letter of the prompt.

@JaimieDodd
Copy link
Author

JaimieDodd commented Mar 27, 2018

Oh okay. In the powershell it says

Cython==0.27.3

@dolang
Copy link
Contributor

dolang commented Mar 27, 2018

Alright, tried to reproduce it with a similar not same environment without luck. Bascially, what the error says is that the sdl2 library is missing. But it should've been installed with python -m pip install kivy.deps.sdl2 which is in your original description somewhere.

I'll have to try reproducing this on another machine again, you could try to pip uninstall ... + pip install ... that dependency in the meantime.

@dolang
Copy link
Contributor

dolang commented Mar 27, 2018

Tried on another machine now, getting the same result (i.e. it works here). What do you have for:

PS  C:\> python -m pip freeze | select-string sdl2

it should give you: kivy.deps.sdl2==0.1.17.

Alternatively, if you have several Python interpreters installed:

PS  C:\> py -3.6 -m pip freeze | select-string sdl2

If one of these two commands doesn't give you the output above, try reinstalling kivy.deps.sdl2.

If they do and it doesn't work, please paste what you get with:

PS C:\> dir C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\share\sdl2\bin

Maybe you have to reinstall the 64-bit Python interpreter. (Just a guess, not sure yet.)

@JaimieDodd
Copy link
Author

I did that and

get kivy.deps.sdl2==0.1.17

I have uninstalled 32-bit and installed 64-bit Python in its place, however, still get this error


H:\untitled2\Scripts\python.exe "C:/Users/DoddJ/PycharmProjects/untitled/KIVY TEST.py"
[INFO   ] [Logger      ] Record log in C:\Users\DoddJ\.kivy\logs\kivy_18-03-28_40.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: pil(['text_sdl2'] ignored)
[CRITICAL] [Window      ] Unable to find any valuable Window provider.

[CRITICAL] [App         ] Unable to get a Window, abort.
 Exception ignored in: 'kivy.properties.dpi2px'
 Traceback (most recent call last):
   File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36\lib\site-packages\kivy\utils.py", line 496, in __get__
     retval = self.func(inst)
   File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36\lib\site-packages\kivy\metrics.py", line 174, in dpi
     EventLoop.ensure_window()
   File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36\lib\site-packages\kivy\base.py", line 127, in ensure_window
     sys.exit(1)
 SystemExit: 1
[CRITICAL] [App         ] Unable to get a Window, abort.

Process finished with exit code 1

@dolang
Copy link
Contributor

dolang commented Mar 27, 2018

Well, I wasn't sure if 32/64-bit could be the problem here. But can you look if the .dll is actually there?

PS C:\> dir C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36\share\sdl2\bin

If it's there, maybe your virus scanner is blocking it, or your firewall (or some other really intrusive software)? This is not something that should happen, imho.

Edit: had a look at my installation again and opened a running application in Process Hacker. This SDL2.dll is custom-built for PyPI and it looks like it's unsigned. Depending on your Windows policy settings, it could be blocked automatically because of that. Maybe the following can help?

Windows 10: Unblock File in Windows 10

@ghost
Copy link

ghost commented Mar 28, 2018

According to earlier comment, you have cython 0.27.3 and the console log says Kivy v1.10.0 ... those versions are not compatible, though I'm not sure exactly why the missing window provider is the first clue to this problem.... Maybe try either using cython 0.25.2 (compatible with 1.10) + reinstall kivy, or alternatively pip install kivy==master with your current cython version?

@JamesTheAwesomeDude
Copy link

I am getting this issue also with Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32

C:\> python3 -m pip show kivy kivy.deps.glew kivy.deps.sdl2
Name: Kivy
Version: 1.10.0
Summary: A software library for rapid development of hardware-accelerated multitouch applications.
Home-page: http://kivy.org
Author: Kivy Team and other contributors
Author-email: kivy-dev@googlegroups.com
License: MIT
Location: c:\users\jedingto\appdata\roaming\python\python36\site-packages
Requires: docutils, Kivy-Garden, pygments
Required-by:
---
Name: kivy.deps.glew
Version: 0.1.9
Summary: Repackaged binary dependency of Kivy.
Home-page: http://kivy.org/
Author: Kivy Crew
Author-email: kivy-dev@googlegroups.com
License: MIT
Location: c:\users\jedingto\appdata\roaming\python\python36\site-packages
Requires:
Required-by:
---
Name: kivy.deps.sdl2
Version: 0.1.17
Summary: Repackaged binary dependency of Kivy.
Home-page: http://kivy.org/
Author: Kivy Crew
Author-email: kivy-dev@googlegroups.com
License: zlib
Location: c:\users\jedingto\appdata\roaming\python\python36\site-packages
Requires:
Required-by:

running it gives the following:

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from kivy.app import App
[INFO   ] [Logger      ] Record log in C:\Users\jedingto\.kivy\logs\kivy_18-05-17_4.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif (img_sdl2, img_pil, img_ffpyplayer ignored)
>>> from kivy.uix.widget import Widget
>>> class PongGame(Widget):
...  pass
...
>>> class PongApp(App):
...  def build(self):
...   return PongGame()
...
>>> PongApp().run()
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\window\window_sdl2.py", line 26, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

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

Despite the existence of the SDL2 DLL:

dir %AppData%\Python\share\sdl2\bin\SDL2.dll
 Volume in drive C is XXXXXX
 Volume Serial Number is 0000-0000

 Directory of C:\Users\USER\AppData\Roaming\Python\share\sdl2\bin

2018-05-17  11:33 AM         1,254,400 SDL2.dll
               1 File(s)      1,254,400 bytes
               0 Dir(s)  161,199,689,728 bytes free

@JamesTheAwesomeDude
Copy link

and I should add that this occurs even if I uninstall kivy.deps.sdl from --user mode and install it into C:\Program Files\Python\share\sdl2 via Administrator Mode, the error is the same:

>>> PongApp().run()
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\window\window_sdl2.py", line 26, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

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

It doesn't even work if I cd right into the directory next to SDL2.dll before running python3

@dolang
Copy link
Contributor

dolang commented May 17, 2018

Alright, there are several things at play here:

  1. the .dll has to exist in that directory
  2. the file ...\site-packages\kivy\deps\sdl2\__init__.py gets loaded and points at the .dll
  3. Windows (or some other intrusive software like some virus scanners) itself doesn't block loading it

So far I've been unable to reproduce it, but 3. is something that can't be excluded.

Another thing you could try: open a command prompt and point the PATH directly at the sdl2 folder. Something like:

\> set PATH=C:\Users\USER\AppData\Roaming\Python\share\sdl2\bin;%PATH%

@JamesTheAwesomeDude
Copy link

JamesTheAwesomeDude commented May 17, 2018

@dolang Well, it seems that adding the SDL2.dll folder to the %PATH% fixes....part of that error. img_sdl2 is now no longer "ignored", but it's still "Unable to find any valuable Window provider". It also gave some slightly different (almost exclusively expanded?) error message

[INFO   ] [Logger      ] Record log in C:\Users\jedingto\.kivy\logs\kivy_18-05-17_15.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO   ] [OSC         ] using <thread> for socket
[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\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    cls = cls()
  File "C:\Users\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
    super(WindowSDL, self).__init__()
  File "C:\Users\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\window\__init__.py", line 899, in __init__
    self.create_window()
  File "C:\Users\jedingto\AppData\Roaming\Python\Python36\site-packages\kivy\core\window\window_sdl2.py", line 269, in create_window
    self.fullscreen, resizable, state)
  File "kivy\core\window\_window_sdl2.pyx", line 110, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy\core/window\_window_sdl2.c:2466)
  File "kivy\graphics\cgl.pyx", line 52, in kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:3044)
  File "kivy\graphics\cgl.pyx", line 60, in kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:2879)
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

I confirmed by repeatedly adding and removing that from the PATH that the presence of img_sdl2 in the "ignored" section depends on that, and that the expanded error text appears or disappears depending on if it could find SDL2 or not.

@dolang
Copy link
Contributor

dolang commented May 17, 2018

Now, the glew dependency should have a folder right next to it (share\glew\bin). What happens if you add that too?

@JamesTheAwesomeDude
Copy link

JamesTheAwesomeDude commented May 17, 2018

Aha!

So, on Windows, it can be "solved" by prepending %AppData%\Python\share\glew\bin;%AppData%\Python\share\sdl2\bin; to PATH:

cmd /C "PATH=%AppData%\Python\share\glew\bin;%AppData%\Python\share\sdl2\bin;%PATH% && python3 -c ^"from kivy.core.window._window_sdl2 import _WindowSDL2Storage^""

But unfortunately this is not a solution per se

How ARE the pip-installed-python-libraries supposed to make their way into the PATH which they must be in to function? (A reboot was insufficient)

@dolang
Copy link
Contributor

dolang commented May 17, 2018

That was just a clue for me to find out whether the libraries are actually blocked or not. Good thing they aren't.

As said above (point 2.), you can see that if you open the __init__.py in site-packages\kivy\deps\..., but that should work out of the box. Now I need to find a way to break mine exactly like in your case. 😄

@JamesTheAwesomeDude
Copy link

Is this of any use?

>>> import pdb
>>> pdb.run()
KeyboardInterrupt
>>> lamb
KeyboardInterrupt
>>> pdb.run("from kivy.core.window._window_sdl2 import _WindowSDL2Storage")
> <string>(1)<module>()
(Pdb) s
--Call--
> <frozen importlib._bootstrap>(966)_find_and_load()
(Pdb)
> <frozen importlib._bootstrap>(968)_find_and_load()
(Pdb)
--Call--
> <frozen importlib._bootstrap>(143)__init__()
(Pdb)
> <frozen importlib._bootstrap>(144)__init__()
(Pdb)
> <frozen importlib._bootstrap>(145)__init__()
(Pdb)
--Return--
> <frozen importlib._bootstrap>(145)__init__()->None
(Pdb)
--Call--
> <frozen importlib._bootstrap>(147)__enter__()
(Pdb)
> <frozen importlib._bootstrap>(148)__enter__()
(Pdb)
--Call--
> <frozen importlib._bootstrap>(157)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(163)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(164)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(165)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(166)_get_module_lock()
(Pdb)
KeyError: 'kivy.core.window._window_sdl2'
> <frozen importlib._bootstrap>(166)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(167)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(168)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(170)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(171)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(174)_get_module_lock()
(Pdb)
--Call--
> <frozen importlib._bootstrap>(58)__init__()
(Pdb)
> <frozen importlib._bootstrap>(59)__init__()
(Pdb)
> <frozen importlib._bootstrap>(60)__init__()
(Pdb)
> <frozen importlib._bootstrap>(61)__init__()
(Pdb)
> <frozen importlib._bootstrap>(62)__init__()
(Pdb)
> <frozen importlib._bootstrap>(63)__init__()
(Pdb)
> <frozen importlib._bootstrap>(64)__init__()
(Pdb)
--Return--
> <frozen importlib._bootstrap>(64)__init__()->None
(Pdb)
> <frozen importlib._bootstrap>(176)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(187)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(189)_get_module_lock()
(Pdb)
> <frozen importlib._bootstrap>(191)_get_module_lock()
(Pdb)
--Return--
> <frozen importlib._bootstrap>(191)_get_module_lock()->_ModuleLock('... 1869402554208
(Pdb)
> <frozen importlib._bootstrap>(149)__enter__()
(Pdb)
--Call--
> <frozen importlib._bootstrap>(78)acquire()
(Pdb)
> <frozen importlib._bootstrap>(84)acquire()
(Pdb)
> <frozen importlib._bootstrap>(85)acquire()
(Pdb)
> <frozen importlib._bootstrap>(86)acquire()
(Pdb)
> <frozen importlib._bootstrap>(87)acquire()
(Pdb)
> <frozen importlib._bootstrap>(88)acquire()
(Pdb)
> <frozen importlib._bootstrap>(89)acquire()
(Pdb)
> <frozen importlib._bootstrap>(90)acquire()
(Pdb)
> <frozen importlib._bootstrap>(91)acquire()
(Pdb)
> <frozen importlib._bootstrap>(92)acquire()
(Pdb)
> <frozen importlib._bootstrap>(101)acquire()
(Pdb)
KeyError: 12616
> <frozen importlib._bootstrap>(101)acquire()
(Pdb)
--Return--
> <frozen importlib._bootstrap>(101)acquire()->None
(Pdb)
KeyError: 12616
> <frozen importlib._bootstrap>(149)__enter__()
(Pdb)
--Return--
> <frozen importlib._bootstrap>(149)__enter__()->None
(Pdb)
KeyError: 12616
> <frozen importlib._bootstrap>(968)_find_and_load()
(Pdb)
--Return--
> <frozen importlib._bootstrap>(968)_find_and_load()->None
(Pdb)
KeyError: 12616
> <string>(1)<module>()
(Pdb)
--Return--
> <string>(1)<module>()->None
(Pdb)
KeyError: 12616
> c:\program files\python36\lib\bdb.py(434)run()
-> exec(cmd, globals, locals)
(Pdb)
> c:\program files\python36\lib\bdb.py(435)run()
-> except BdbQuit:
(Pdb)
> c:\program files\python36\lib\bdb.py(438)run()
-> self.quitting = True
(Pdb)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python36\lib\pdb.py", line 1572, in run
    Pdb().run(statement, globals, locals)
  File "C:\Program Files\Python36\lib\bdb.py", line 434, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 149, in __enter__
  File "<frozen importlib._bootstrap>", line 101, in acquire
KeyError: 12616

@JamesTheAwesomeDude
Copy link

JamesTheAwesomeDude commented May 17, 2018

Well,

some further testing reveals that it functions correctly if BOTH kivy.deps.glew AND kivy.deps.sdl2 are installed in Administrator mode.

I think the problem lies with too much being hardcoded into site-packages\kivy\deps\*\__init__.py

I wonder if there's a more canonical way to add DLLs from Pip packages into the PATH...?

@dolang
Copy link
Contributor

dolang commented May 17, 2018

Good question, but I don't know how the team arrived at their current solution. At least we could narrow it down now, so that's a step forward.

By the way, are you familiar with virtualenv. I normally use those and rarely have problems. So for now you could do (admin):

py -m pip install virtualenv

Normal user account (.venv is my preferred name of the directory of the virtualenv, change as you like):

py -m virtualenv .venv
.venv\Scripts\activate
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
python -m pip install kivy

optionally add: python -m pip install kivy.deps.gstreamer

Hope I got that all right.

@LaurentBerger
Copy link

Configuration windows 10 python 363 (visual studio 2017):

[INFO   ] [Logger      ] Record log in C:\Users\Laurent\.kivy\logs\kivy_18-08-23_29.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)]
[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
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.6.0 NVIDIA 390.77'>
[INFO   ] [GL          ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO   ] [GL          ] OpenGL renderer <b'GeForce GTX 970/PCIe/SSE2'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 6
[INFO   ] [GL          ] Shading version <b'4.60 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   ] [Text        ] Provider: sdl2
Standard library module invoked user code during import; breakpoints disabled for invoked code.
[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available
[WARNING] [Accordion   ] not enough space for displaying all children
[WARNING] [Accordion   ] need 132px, got 84px
[WARNING] [Accordion   ] layout aborted.
[WARNING] [Accordion   ] not enough space for displaying all children
[WARNING] [Accordion   ] need 132px, got 84px
[WARNING] [Accordion   ] layout aborted.
[INFO   ] [Base        ] Leaving application in progress...
The thread 'MainThread' (0x13ec) has exited with code 0 (0x0).

I 've got same issue and I solve it and my solution is not a good one. I copy all dlls (share/sdl2 share/angle share/glew share/gstreamer) in a repository and I add this repository to path variable.

I installed kivy using admin right (https://kivy.org/docs/installation/installation-windows.html) and i tried to run using user right (user laurent )then error happens : [CRITICAL] [Window ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.

Copying all dlls in new folder solves issues. My question is then How can I install kivy to run kivy with user privilege ?

PS sorry I 'm not good in english and python

@shenryHen
Copy link

By the way, are you familiar with virtualenv. I normally use those and rarely have problems. So for now you could do (admin):

py -m pip install virtualenv

Normal user account (.venv is my preferred name of the directory of the virtualenv, change as you like):

py -m virtualenv .venv
.venv\Scripts\activate
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
python -m pip install kivy

I tried using virtualenv and it did not work. I still got a similar error. I also added C:\Program Files\Python37\share\sdl2\bin and C:\Program Files\Python37\share\angle\bin to my PATH already. And I did what I think @LaurentBerger did, copy those two files into another directory, and then add that directory to the path. Using virtualenv with the two PATH options did not work for me as well.

I'm using python 3.7 so I installed kivy.deps.angle instead of kivy.deps.glew

Logs:

[INFO   ] [Logger      ] Record log in C:\Users\henry\.kivy\logs\kivy_18-09-15_16.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 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.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    cls = cls()
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
    super(WindowSDL, self).__init__()
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\lib\site-packages\kivy\core\window\__init__.py", line 968, in __init__
    self.create_window()
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\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\henry\DOCUME~1\SIDEPR~1\fps\venv\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.

@tito
Copy link
Member

tito commented Oct 4, 2018

On this issue, i've seen mixing libraries architectures (Python in 64 bits, SDL2 in 32 bits), so that's a first stop. And yes, if you mixed the arch, the libraries won't be used at all and Kivy won't work.
Installation of SDL2 via kivy.deps.sdl2 should works.

@tito tito closed this as completed Oct 4, 2018
@tito tito self-assigned this Oct 4, 2018
@tito tito added this to todo in Sprint pycon-fr 2018 via automation Oct 4, 2018
@tito tito moved this from todo to closed in Sprint pycon-fr 2018 Oct 4, 2018
@talhaanwarch
Copy link

I am using python 3.7 and i am getting this error. kivy version is 1.10.1
how should i resolve it

@hariharasudhand
Copy link

same here python 3.7 , kivy version is 1.10.1 and tried all ways to load the DLL but shows no mercy.

@matham
Copy link
Member

matham commented May 30, 2019

Please see #6342.

@4nkitpatel
Copy link

https://stackoverflow.com/questions/49466785/kivy-error-python-2-7-sdl2-import-error/49477111#49477111

This Solve My Problem Which is The same one you Had
Hope this will help You

@erinreneeee
Copy link

I had the same issue. This video may help those who are visual! https://youtu.be/gt-qndBYrCQ

@joyb0218
Copy link

Had many issues, but managed to work them out. Here's what I learned (using PyCharm):

  1. You can't install Kivy on Python 3.8. If you have 3.8, go back to 3.7.
  2. I installed all of the packages that someone else posted a picture of. I'll post mine here. Go to your project interpreter and hit the "+" button to add them all. They should successfully install.
    pkg1
    pkg2
  3. Was getting the window sdl2 error. Watched this short video (https://www.youtube.com/watch?v=e_jv8KsYBrs&t=212s) (may God bless this person) and changed my paths in my system environment.
  4. I then reinstalled the dependencies from the Kivy website -- AND IT WORKED!!!

Hope this helps someone!!!!

@primakov
Copy link

primakov commented Mar 9, 2020

By the way, are you familiar with virtualenv. I normally use those and rarely have problems. So for now you could do (admin):

py -m pip install virtualenv

Normal user account (.venv is my preferred name of the directory of the virtualenv, change as you like):

py -m virtualenv .venv
.venv\Scripts\activate
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
python -m pip install kivy

I tried using virtualenv and it did not work. I still got a similar error. I also added C:\Program Files\Python37\share\sdl2\bin and C:\Program Files\Python37\share\angle\bin to my PATH already. And I did what I think @LaurentBerger did, copy those two files into another directory, and then add that directory to the path. Using virtualenv with the two PATH options did not work for me as well.

I'm using python 3.7 so I installed kivy.deps.angle instead of kivy.deps.glew

Logs:

[INFO   ] [Logger      ] Record log in C:\Users\henry\.kivy\logs\kivy_18-09-15_16.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 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.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    cls = cls()
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
    super(WindowSDL, self).__init__()
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\lib\site-packages\kivy\core\window\__init__.py", line 968, in __init__
    self.create_window()
  File "C:\Users\henry\DOCUME~1\SIDEPR~1\fps\venv\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\henry\DOCUME~1\SIDEPR~1\fps\venv\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.

Try to manually copy glew,sdl2 folders and init.py from ../site-packages/kivy_deps to ../site-packages/kivy/deps.
It worked for me

@matham matham added the Component: documentation Documentation or examples label Nov 1, 2020
@rpopovici
Copy link

rpopovici commented Feb 2, 2021

For windows 10 If I am installing in a non standard path without virtenv, this works for me:

import os
os.environ["KIVY_NO_ARGS"] = "1"
os.environ['KIVY_IMAGE'] = "pil,sdl2" # use pil instead of SDL2 image if you get the libpng16 error
# you must add to the path the location of your SDL2 binaries
os.environ['PATH'] += ';' + os.path.expandvars('%AppData%\\Python\\share\\glew\\bin')
os.environ['PATH'] += ';' + os.path.expandvars('%AppData%\\Python\\share\\sdl2\\bin')

from kivy.app import App
...

Apparently there are some issues with sdl2 dependency installation on windows. I don't know exactly what is the problem. It might have something to do with the fact that sdl2 package is installing the wrong version of libpng16-16.DLL(206KB). Another solution might be to copy the libpng16-16.DLL(2MB) from gstreamer to your app folder if you get a SDL2_image error. #6335

On MacOS Big Sur: I had to clear the code signing on the sdl2 libs in order to start the app. Found the solution in this pyinstaller commit pyinstaller/pyinstaller@de511a1

def install_kivy():
        subprocess.check_call([PYTHON_PATH, '-m', 'pip', 'install', '--user', '--no-cache-dir', 'kivy[base]'])
        user_site_packages_path = site.getusersitepackages()
        SDL2_DYLIB_PATH = os.path.join(user_site_packages_path, './kivy/.dylibs/SDL2')
        SDL2_IMAGE_DYLIB_PATH = os.path.join(user_site_packages_path, './kivy/.dylibs/SDL2_image')
        subprocess.check_call(['codesign', '--remove-signature', SDL2_DYLIB_PATH])
        subprocess.check_call(['codesign', '--remove-signature', SDL2_IMAGE_DYLIB_PATH])
...

@OrangeDog
Copy link

This also appears to fail with Microsoft Store versions of Python, as the python3X.dll cannot be found.

@axelpello
Copy link

Alright, tried to reproduce it with a similar not same environment without luck. Bascially, what the error says is that the sdl2 library is missing. But it should've been installed with python -m pip install kivy.deps.sdl2 which is in your original description somewhere.

I'll have to try reproducing this on another machine again, you could try to pip uninstall ... + pip install ... that dependency in the meantime.

You are a lifesaver! uninstalling and then reinstalling the kivy.deps.sdl2 in the cmd did it for me. I was up late trying to fix this. Thank you so much!

@noiia
Copy link

noiia commented Jun 5, 2022

Gosh... thank you guys, you saved me a lot of time ^^.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests