sdl2 error - dll load failed

120 views
Skip to first unread message

JordonMMG

unread,
Nov 20, 2019, 3:25:03 AM11/20/19
to Kivy users support
Trying to follow a tutorial from here: https://techwithtim.net/tutorials/kivy-tutorial/setup/

The code is:

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


class MyApp(App):
    def build(self):
        return Label(text="tech with tim")


if __name__ == "__main__":
    MyApp().run()


The error i get is about 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: The specified module could not be found.
  File "C:\Users\JordonMMG\AppData\Roaming\Python\Python37\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\JordonMMG\AppData\Roaming\Python\Python37\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

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

Even when I use the demo code from the front page of Kivy.org, I get the same error. I've done multiple uninstall/reinstallitions and specifically targeted the sdl2 from the installation guide with no errors in the installation. However, trying to run these I get these errors.

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

class TestApp(App):
    def build(self):
        return Button(text='Hello World')

TestApp().run()



When I enter PIP, i get the below so I have no clue if it's even working properly despite the installation success messages:
Traceback (most recent call last):
 
File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main
   
"__main__", mod_spec)
 
File "c:\program files\python37\lib\runpy.py", line 85, in _run_code
   
exec(code, run_globals)
 
File "C:\Program Files\Python37\Scripts\pip.exe\__main__.py", line 9, in <module>
TypeError: 'module' object is not callable

Robert Flatt

unread,
Nov 20, 2019, 11:47:32 AM11/20/19
to Kivy users support
Did you install the dependencies ?

Type:
pip list
You should see int part

Kivy                 1.11.1
kivy-deps.glew       0.1.12
kivy-deps.gstreamer  0.1.17
kivy-deps.sdl2       0.1.22

If not then read the install instructions:

where you will see:
python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.22 kivy_deps.glew==0.1.12

python -m pip install kivy_deps.gstreamer==0.1.17

JordonMMG

unread,
Nov 20, 2019, 1:04:13 PM11/20/19
to Kivy users support
When I type pip list, I get the following:
C:\Users\JordonMMG>pip list
Traceback (most recent call last):
  File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python37\Scripts\pip.exe\__main__.py", line 9, in <module>
TypeError: 'module' object is not callable

I have reinstalled python 3.7.5 multiple times, making sure to select pip (I select every checkbox).and have tried to install it from the instructions at https://pip.pypa.io/en/stable/installing/ as well after getting the above error. That doesn't resolve the issue.

Right now, I've uninstalled python and have deleted all files not cleaned up by the process. So no pip or python folder exists between Programs, Programs(x86), Appdata\Local, Appdata\LocalLow, and Appdata\Roaming. 

Here is a screen recording trying to follow the instructions and having the same issues yet again:


Here you see that when I update pip, it breaks.  So I attempt another installation, this time without updating pip:


Still get sdl2 errors after following the instructions. 

JordonMMG

unread,
Nov 20, 2019, 3:56:22 PM11/20/19
to Kivy users support
Joined discord to discuss as well - I've provided a zip of the logs from installation through to attempting to run the kivy program from the home page (with logs). File is on the #support channel.

Robert Flatt

unread,
Nov 20, 2019, 4:56:30 PM11/20/19
to Kivy users support
As I understand it using a clean Python 3.7 install, pip breaks after typing the following line from the Kivy install instructions (as shown by 5:16 in the first video):

python -m pip install --upgrade pip wheel setuptools virtualenv

The issue is I think only about Kivy because Kivy install asks for the versions of other tools to be current. Kivy is not installed.
This I suspect a Python/pip install issue, but what?
No offense intended, but the question I need to ask myself is what might a noob do? ;)

Did you close and open the Command Prompt after installing Python?

My friend Google showed me some similar history, but not a resolution.
https://github.com/pypa/pip/issues/2824

There is a Linux example https://stackoverflow.com/questions/49836676/error-after-upgrading-pip-cannot-import-name-main
Is it possible Python was ever installed with Admin privilege?


Personally I have never used that line in the instructions.
Because I don't use virtualenv, and I keep pip current whenever pip tells me to using pip's instructions.

You could try (after uninstall and install Python 3.7) the pip install and upgrade pip on its own first.

python -m pip install --upgrade pip


Robert Flatt

unread,
Nov 20, 2019, 4:58:51 PM11/20/19
to Kivy users support
And one more is Python 3.8 still installed?

JordonMMG

unread,
Nov 20, 2019, 5:04:00 PM11/20/19
to Kivy users support
No offense taken!

I don't recall running it as admin but I know for sure this attempt was not.

I'm using 3.7.5 and have cleared all other possible python files when i did the uninstall. 3.8 should not exist anywhere on my system either (other than the installer still in my download folder).

Leaving pip on the version that comes with 3.7.5 means i can type pip or pip list and it will work. I don't know why the updated version breaks for me.

Despite that, I still run into the sdl2 error whether i use the python shell or if i launch via CMD. Folks on discord asked for logs throughout the installation process and that's as far as I've been able to get with this. 

Robert Flatt

unread,
Nov 20, 2019, 6:51:45 PM11/20/19
to Kivy users support
Ok so I understand that 'pip list' showing (I infer this is what you see):

Kivy                 1.11.1
kivy-deps.glew       0.1.12
kivy-deps.gstreamer  0.1.17
kivy-deps.sdl2       0.1.22

Makes an sdl2 load problem look like a Kivy issue, but it is almost certainly not. It is a Python package loading issue. Other packages will probably also demonstrate the issue in their own way. The first thing in the Kivy install instruction is update pip, that doesnt work.

We have to find the first issue, not the last issue.

pip not updating its self is indicative of a Python package management issue.

Since this is a clean install, presumably somewhere there is some legacy information from a previous install.
(maybe even from the install of some other program that uses python).
Best guess pip is woking in the wrong place or with directories with the wrong permissions.

If this were a common issue there would be a zillion posts about it on the net, something is different on this machine.

I understand that the previous install directories are removed, but state is stored elsewhere too.

Check the PATH environment variable for both User and Admin  (I know given the previous it should not matter, do it anyway. In cases like this 'should' is actually the issue)
Under 'Admin' there will be no PATH entry referencing Python
Under 'User' PATH there will be two entries, at the top.
These will look similar to ('YOU' is replaced with your account name):

C:\Users\YOU\AppData\Local\Programs\Python\Python37\Scripts\
C
:\Users\YOU\AppData\Local\Programs\Python\Python37\

Are there any entries other than these two at the top under User?
Take care, just deleting stuff here might break somthing else. Understand anything you choose to delete.





Robert Flatt

unread,
Nov 20, 2019, 6:59:03 PM11/20/19
to Kivy users support
There may also be a PYTHONPATH environment variable too. If not its OK.

JordonMMG

unread,
Nov 21, 2019, 12:28:10 AM11/21/19
to Kivy users support
I only have one login for the account, not sure how to view for admin other than what i see for my user account. The first one is for the top box, the second one is from the bottom box. If you're asking if these are removed when I do the uninstallation, I haven't even tried to check these. I can give it a whirl after I post this. I do recall seeing a post where someone suggested that the folder ending in a slash could be causing problems.




Here is the pip list image:



Elliot Garbus

unread,
Nov 21, 2019, 12:41:51 AM11/21/19
to kivy-...@googlegroups.com

Looks like you might have python installed in 2 places, at least you have env variables pointing in 2 places…

One is your user directory C:\Users…

And the other is your Program Files… C:\Program Files…

 

On my Windows System I have Python installed at c:\Users…

NOT at C:\Program Files

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/67d0b124-82cb-498f-bd6c-6fd33ad47017%40googlegroups.com.

 

JordonMMG

unread,
Nov 21, 2019, 1:08:09 AM11/21/19
to Kivy users support
It was installed in users until I began to install it for "all users." 

So i did another uninstall and cleaned out every python reference in the env path in the user and system windows. This time i was able to launch the hello world app from Kivy's home page. Now I did get warnings during install. but since it's working i'll mark this as complete.  Should i be concerned about the warnings despite it working?


Robert Flatt

unread,
Nov 21, 2019, 1:13:41 AM11/21/19
to Kivy users support
The bottom box is "System Variables", there should not be any Python entries here.
These I suspect reflect past installs as Admin
Delete all of them.

The top box is "User Variables for JordonMMG", there should be two entries here at the top.
These I suspect reflect past installs as User.
Is it correct that you tried to install in two different locations (..AppData..., and C:\Program Files)?
Installing in "C:\Program Files" will definitely give permission problems.
Delete these.

The actual files should be in in Appdata, the PATH should reflect this

Just saw your post, will read and comment

The actual files need to be

On Wednesday, November 20, 2019 at 7:41:51 PM UTC-10, Elliot Garbus wrote:

Looks like you might have python installed in 2 places, at least you have env variables pointing in 2 places…

One is your user directory C:\Users…

And the other is your Program Files… C:\Program Files…

 

On my Windows System I have Python installed at c:\Users…

NOT at C:\Program Files

 

From: JordonMMG
Sent: Wednesday, November 20, 2019 10:28 PM
To: Kivy users support
Subject: [kivy-users] Re: sdl2 error - dll load failed

 

I only have one login for the account, not sure how to view for admin other than what i see for my user account. The first one is for the top box, the second one is from the bottom box. If you're asking if these are removed when I do the uninstallation, I haven't even tried to check these. I can give it a whirl after I post this. I do recall seeing a post where someone suggested that the folder ending in a slash could be causing problems.

 

 

 

 

Here is the pip list image:

 

 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Robert Flatt

unread,
Nov 21, 2019, 1:17:05 AM11/21/19
to Kivy users support
Now what is in your environment PATH variables?

Seems strange the files are installed under Roaming, not Local, but I don't think this is an issue.

Robert Flatt

unread,
Nov 21, 2019, 1:20:12 AM11/21/19
to Kivy users support
Can you upgrade pip?

JordonMMG

unread,
Nov 21, 2019, 1:24:10 AM11/21/19
to Kivy users support
Yes - pip is 19.3.1 now and no issues.

So i only ever let the python installer choose it's location. When you uncheck the box for "all users" it changes its path. Right now it gots to C:\program...   for All Users.

The users path is empty. The system path has been updated:


Robert Flatt

unread,
Nov 21, 2019, 1:34:49 AM11/21/19
to Kivy users support
That is good news on updating pip, that is the test of the issue.

Hopefully the 'all users' install addressed the permissions issue that occurs installing in in Program Files.

Installing is the easy part, writing reliable apps - that is where the fun starts.  :)

JordonMMG

unread,
Nov 21, 2019, 1:39:43 AM11/21/19
to Kivy users support
:D Lol yes now the real work starts!!!

For additional thought, my not having CMD in the kivy_env i think may have been part of the problem as well. I never could get it to activate - probably was doing something wrong on the part all along and the rest was red herring...which is typical of me and newbness.

Robert Flatt

unread,
Nov 21, 2019, 1:48:51 AM11/21/19
to Kivy users support
Oh, wait, I just saw this:

Should i be concerned about the warnings despite it working?
 
Yes, sort of. It is broken and you need to add it to the path.
What this means is wheel is installed for one user JprdonMMG, but it not going to be found.
So it is not really updated, it will actually use the old wheel.exe
It looks looks like it is good but it isn't

Since there is only one user, and if this gets added to the PATH, all will be OK.
But the AppData dir needs to be before the Program Files dir in the search path.
I think if you add in the JordonMMG PATH (user has permission for this) all will be ok - but check from the Command Prompt with ECHO.

Robert Flatt

unread,
Nov 21, 2019, 1:52:52 AM11/21/19
to Kivy users support

my not having CMD in the kivy_env i think may have been part of the problem as well.

Not certain I know what is  "kivy_env".   Assuming package install works, and pip list shows the previously listed entries you should be good to go (and PATH as in my previous post).

Robert Flatt

unread,
Nov 21, 2019, 4:20:37 PM11/21/19
to Kivy users support
I keep thinking in the long term you will be better off with single user Python install.
The multi user is the old way, there can be non obvious issues (like wheel).
Basically one less uncertainty.
Reply all
Reply to author
Forward
0 new messages