Kivy error (python 2.7) : sdl2 import error
Asked Answered
C

7

4

I'm trying to use kivy on my Python 2.7 project (in a PyCharm - Windows 10 environment), but I get the following error.

If someone can help me ? Thanks !

PS : I tried many times uninstalling/reinstalling libraries etc and doing what suggested on posts like this one, but it doesn't work : Kivy not working (Error: Unable to find any valuable Window provider.)

[INFO   ] [Logger      ] Record log in C:\Users\cyril\.kivy\logs\kivy_18-03-25_0.txt
 C:\Users\cyril\venv\lib\site-packages\kivy\modules\__init__.py:128: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
   if path not in sys.path:
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif (img_sdl2, img_pil, img_ffpyplayer ignored)
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: Le module sp�cifi� est introuvable.
  File "C:\Users\cyril\venv\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\cyril\venv\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.

Process finished with exit code 1
Cephalothorax answered 24/3, 2018 at 15:57 Comment(2)
Are the error messages complete? There should be an opening parenthesis and probably something more in the first error message (the one with line 59).Cirrus
I edited the post with the full errorCephalothorax
G
6

Problem

It is looking for the Kivy dependencies (e.g. sdl2) in your virtualenv.

Solution

I have encountered the same problem. I did the following and it solved the problem.

Environment

  • Windows 10
  • PyCharm Community
  • Python 3.5
  • Kivy dependencies installed (docutils, pygments, pypiwin32, kivy.deps.sdl2, kivy.deps.glew, kivy.deps.gstreamer) and for Python 3.5+ (kivy.deps.angle)

PyCharm IDE

  1. Open the project
  2. Click File
  3. Click Settings...
  4. Click Project Interpreter
  5. On the right panel, click the drop down list for Project Interpreter
  6. Select the location where the Python interpreter is installed e.g. C:\Users\user-name\AppData\Local\Programs\Python\Python35\python.exe
  7. Click OK until you exit the Settings window
  8. Run your program

Output

Img01 - SDL2 Error Img02 - Python Interpreter Settings Before Change Img03 - Python Interpreter Settings Changed Img04 - Run Kivy App Img05 - SDL2

Guild answered 25/3, 2018 at 14:46 Comment(0)
A
3

if you have not installed all dependencies then the error will occur , Instead of Project Interpreter use the pycharm terminal Then install the following

1.python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.* kivy_deps.glew==0.1.*

  1. python -m pip install kivy_deps.gstreamer==0.1.*

  2. python -m pip install kivy_deps.angle==0.1.*

  3. python -m pip install kivy==1.11.1

Acrylonitrile answered 18/3, 2020 at 11:57 Comment(0)
C
1

Checked everything, reinstalled etc. still no luck, but after using the -d (debug) option the errormessage expanded and suggested there might be another sdl2.dll in the path. After some trial and error I found one in windows\system32. Moving it out of the way made the error disappear.

Centigrade answered 31/5, 2020 at 9:51 Comment(0)
C
1

I tried running the app in virtual environment and it worked.

Chenee answered 15/9, 2020 at 13:40 Comment(0)
B
1

Lets be real, use a virtual environment. Kivys documentation even highly recommends this aswell.

Repeating this step always gives me a runnable kivy-example First uninstall all kivy-related librarys you already have installed.

python -m pip uninstall -y kivy.deps.glew kivy.deps.gstreamer kivy.deps.sdl2 kivy.deps.angle

Upgrade pip, wheel, setuptools and setuptools

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

Create a venv in your project folder and activate it

python -m virtualenv venv
venv\Scripts\activate 

(on bash put "source" in front.)

Install kivys dependecies to your virtual environment.

python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.* 

If you want video and audio support:

python -m pip install kivy_deps.gstreamer==0.1.*

On Python 3.5+ you can opt to use Angle astead glew, so do either/or:

python -m pip install kivy_deps.glew==0.1.*
python -m pip install kivy_deps.angle==0.1.*

Install kivy

python -m pip install kivy==1.11.1 kivy_examples==1.11.1

After that do

python venv\share\kivy-examples\demo\showcase\main.py

Source: https://kivy.org/doc/stable/installation/installation-windows.html

If it still errors with "[CRITICAL] [App ] Unable to get a Window, abort.", CMD:

set USE_SDL2=1
set USE_GSTREAMER=1

Terminal:

export USE_SDL2=1
export USE_GSTREAMER=1
Benioff answered 9/10, 2020 at 12:52 Comment(0)
A
0

Just impossible, tried all that with 3.7 64 on win10, same exception...This thing just doesn't work, guess I will have to try Beeware instead. Disappointing

Ahrendt answered 13/7, 2020 at 12:18 Comment(0)
W
0

Instead run in your IDE, try to run the program in cmd or powershell by python <filename>. It works for me.

Wharton answered 4/7, 2022 at 5:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.