Getting Thonny working with Kivy

1,170 views
Skip to first unread message

J.V

unread,
May 18, 2017, 8:58:14 AM5/18/17
to thonny
I'm trying to get Thonny working with Kivy. I could use some help!
I've tried everything.

Installed many many packages from inside of thonny.
it wont open any window when i press start.
Thanks!

Aivar Annamaa

unread,
May 18, 2017, 11:23:32 AM5/18/17
to thonny
Hi!

I assume you're working on Windows and didn't get any error message -- just the Kivy window didn't appear.
Looks like Kivy doesn't like a detail in the approach how Thonny runs programs. I'll see what can be done (https://bitbucket.org/plas/thonny/issues/267/kivy-process-doesnt-like).

The workaround is to select "Tools => Open system shell" and run your program there (python your_script.py)

best regards,
Aivar

Aivar Annamaa

unread,
May 18, 2017, 2:18:19 PM5/18/17
to thonny
I think I got this problem fixed, but the release is a few days away.

You can apply this fix in your installed Thonny by opening C:\Users\<your username>\AppData\Local\Programs\Thonny\Lib\site-packages\thonny\running.py and deleting following lines in method CPythonProxy._start_new_process:

            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

best regards,
Aivar

Col Thompson

unread,
Jan 7, 2019, 5:01:43 AM1/7/19
to thonny
Fairly new to Python - have used IDLE last year trying to teach to Year 11 students.  Thonny is a great teaching tool however, I want to use Kivy to create apps.  I have tried to follow several "fixes" suggested however I keep getting the following error.  Can anyone help please?

PS it works in IDLE and Visual Code Editor but I particularly want to use Thonny as it is a much better teaching tool. 

Python 3.7.1 (bundled)
>>> 
========================= RESTART =========================
>>> %Run p8HelloWorld.py
[INFO   ] [Logger      ] Record log in C:\Users\colin\.kivy\logs\kivy_19-01-07_2.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 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\colin\AppData\Roaming\Python\Python37\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\colin\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py", line 290, in _custom_import
    module = self._original_import(*args, **kw)
  File "C:\Users\colin\AppData\Roaming\Python\Python37\site-packages\kivy\core\window\window_sdl2.py", line 26, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage
  File "C:\Users\colin\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py", line 290, in _custom_import
    module = self._original_import(*args, **kw)

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

Aivar Annamaa

unread,
Jan 7, 2019, 6:07:48 AM1/7/19
to thonny
Hi!

How did you install Kivy?

I followed instructions given in https://kivy.org/doc/stable/installation/installation-windows.html in Windows Thonny 3.0.8 and after this I could run the Hello World example without problems. It's a pity kivy installation is so complex. For this reason I didn't bother to use "Tools => Manage packages" but used "Tools => Open system shell" to execute following commands copied from the instructions:
  • python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
  • python -m pip install kivy.deps.angle
  • python -m pip install kivy
best regards,
Aivar

Col Thompson

unread,
Jan 7, 2019, 6:47:51 PM1/7/19
to thonny
Hi Aivar,

I followed your instructions below via Thonny's "Open system shell" and still no luck.  Same error.  Do you think it might be something to do with the fact that Python was installed earlier with IDLE.  Will try with a clean installation on another device and see how I go.

Also can you recommend somewhere that might be a good tutorial site to use with 16 year olds in school that could be used to learn about Thonny?

Thanks
Colin

Col Thompson

unread,
Jan 7, 2019, 8:18:21 PM1/7/19
to thonny
Hi again Aivar,

Eventually got it working.  I uninstalled Thonny and original Python - reinstalled Thonny - still didn't work

Uninstalled everything again and this time searched and removed all Kivy files found in AppData paths (and I suspect this was the whole issue as I had previously installed Kivy previously from their website instructions via command prompt).

Then reinstalled Thonny and followed your instructions and it worked.  Thanks so much for your help.  Still interested in any tutorials on Thonny that might be helpful to 16 year old students.

Thanks again,
Colin

Col Thompson

unread,
Jan 8, 2019, 2:24:02 AM1/8/19
to thonny
Oh, one more thing.  Some of my students have Macs :===(

Can I follow the same PIP steps below on Macs?

Aivar Annamaa

unread,
Jan 9, 2019, 3:04:59 PM1/9/19
to thonny
Looks like it's more complicated on mac: https://kivy.org/doc/stable/installation/installation-osx.html#installation-osx

Unfortunately I don't know any comprehensive Thonny tutorials. Real Python recently published this: https://realpython.com/python-thonny/. Maybe this is enough for your purposes?

best regards,
Aivar
Reply all
Reply to author
Forward
0 new messages