3

I installed kivy with:

sudo apt-get install python3-kivy

When I run a simple hello world button program from the terminal, it does not display a window, but it doesn't show an error message either. What should I do? my code:

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

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


Sample().run()

P.S. Python 3.6.5, kivy 1.9.1

Edit: as @khaled khalil suggested, i tried the solution. Terminal output:

[INFO   ] [Logger      ] Record log in /home/shamildacoder/.kivy/logs/kivy_18-07-18_1.txt
[INFO   ] [Kivy        ] v1.9.1
[INFO   ] [Python      ] v3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0]
[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
[INFO   ] [Text        ] Provider: sdl2
[DEBUG  ] [App         ] Loading kv <./hi.kv>
[DEBUG  ] [App         ] kv <./hi.kv> not found
[DEBUG  ] [Window      ] Ignored <egl_rpi> (import error)
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[DEBUG  ] [Window      ] Ignored <x11> (import error)
[CRITICAL] [Window      ] Unable to find any valuable Window provider at all!
egl_rpi - ImportError: cannot import name 'bcm'
  File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "/usr/lib/python3/dist-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module>
    from kivy.lib.vidcore_lite import bcm, egl

sdl2 - TypeError: expected bytes, str found
  File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 67, in core_select_lib
    cls = cls()
  File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 138, in __init__
    super(WindowSDL, self).__init__()
  File "/usr/lib/python3/dist-packages/kivy/core/window/__init__.py", line 722, in __init__
    self.create_window()
  File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 237, in create_window
    self.fullscreen, resizable, state)
  File "kivy/core/window/_window_sdl2.pyx", line 94, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:2204)

x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
  File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)

[CRITICAL] [App         ] Unable to get a Window, abort.
 Exception ignored in: 'kivy.properties.dpi2px'
 Traceback (most recent call last):
   File "/usr/lib/python3/dist-packages/kivy/utils.py", line 513, in __get__
     retval = self.func(inst)
   File "/usr/lib/python3/dist-packages/kivy/metrics.py", line 175, in dpi
     EventLoop.ensure_window()
   File "/usr/lib/python3/dist-packages/kivy/base.py", line 126, in ensure_window
     sys.exit(1)
 SystemExit: 1
[CRITICAL] [App         ] Unable to get a Window, abort.
shamilpython
  • 479
  • 1
  • 5
  • 18
  • What is the running Cython version? – ikolim Jul 06 '18 at 15:28
  • print(cython.__version__) returns 0.28.3 – shamilpython Jul 07 '18 at 06:58
  • Kivy 1.9.1 is working/compatible with Cython==0.23.1. Down grade by sudo pip3 install --upgrade cython==0.23.1 and reinstall Kivy. [Kivy & Cython Working Versions](https://kivy.org/docs/installation/deps-cython.html) – ikolim Jul 07 '18 at 13:18
  • I don't think Cython is related here, since he installed kivy pre-compiled from package manager. @shamilpython, open kivi configuration ("~/.kivy/config.ini") with a text editor, under [kivy] section find the line "log_level = info", change "info" with "debug", save the file and run your code again and update your question with the terminal output. If still nothing suspicious you could try with "trace" in place of "debug" – Khaled Khalil Jul 07 '18 at 18:49
  • look at these solutions: https://stackoverflow.com/questions/40697876/kivy-unable-to-get-a-window-abort – Inder Jul 18 '18 at 04:31
  • @KhaledKhalil i added the terminal output – shamilpython Jul 18 '18 at 04:35

0 Answers0