![]() |
Error when running kivy on python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Error when running kivy on python (/thread-40185.html) |
Error when running kivy on python - janeik - Jun-16-2023 desktop pc, win 10 , python 3.11, kivy 2.2 Hello. I am trying to run this code to confirm setup before I dive into python and kivy trying to achieve my goal. The code is from an slightly changed example, viewing a youtube video. The result should show a map beeing able to zoom and a position on map. Any wizzards out there who can help me code to work? Is this error due to wrong setup of python (no indication during setup of erroor),or programming? Thank you for any guideance. Here is the code: import kivy kivy.require('2.2.0') # replace with your current kivy version ! from kivymd.app import MDAppApp from kivy_garden.mapview import MapView class MyApp(MDApp): def build(self): mapview = MapView(zoom=10, Lat=36, Lon=-115) return mapview MapViewApp().run()[error]IndentationError: expected an indented block after function definition on line 10[output]None observed[/output][/error] RE: Error when running kivy on python - menator01 - Jun-16-2023 Check your indent on the build function RE: Error when running kivy on python - janeik - Jun-16-2023 (Jun-16-2023, 01:34 PM)menator01 Wrote: Check your indent on the build functionThanks. I arranged the block elements at, hopefully, right spot. There is still something to correct according to this errormsg(at bottom). Any hints? Thank You.
RE: Error when running kivy on python - deanhystad - Jun-16-2023 The error says it cannot find a module named "kivymd". Did you install kivymd? Installing kivy does not install kivymd. When you type "pip list" in a command shell, does it list kivymd? RE: Error when running kivy on python - janeik - Jun-16-2023 (Jun-16-2023, 04:59 PM)deanhystad Wrote: The error says it cannot find a module named "kivymd". Did you install kivymd? Installing kivy does not install kivymd. No it wasnt listed. so I installed it ver.1.1.1 Running this code from kivymd.app import MDApp from kivy_garden.mapview import MapView class MyApp(MDApp): def build(self): mapview = MapView(zoom=10, Lat=36, Lon=-115) return mapview MapViewApp().run()gives new error:
RE: Error when running kivy on python - janeik - Jun-16-2023 (Jun-16-2023, 04:59 PM)deanhystad Wrote: The error says it cannot find a module named "kivymd". Did you install kivymd? Installing kivy does not install kivymd. I tried to change code to: [python][ from kivymd.app import MDApp from kivy_garden.mapview import MapView class MyApp(MDApp): def build(self): mapview = MapView(zoom=10, Lat=36, Lon=-115) return mapview MyApp().run() /python] Got this error:
RE: Error when running kivy on python - janeik - Jun-16-2023 No errors, but sadly, no map seen on screen. from kivy.config import Config Config.set('kivy','keyboard_mode','systemanddock') from kivymd.app import MDApp from kivy_garden.mapview import MapView class MyApp(MDApp): def build(self): mapview = MapView(zoom=10, Lat=36, Lon=-115) return mapview if __name__ == '__main__': MyApp().run()[output]C:\Users\jan-e>python d:\mapfiler\main.py [INFO ] [Logger ] Record log in C:\Users\jan-e\.kivy\logs\kivy_23-06-16_29.txt [INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.3 [INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.1 [INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.6.0 [INFO ] [Kivy ] v2.2.0 [INFO ] [Kivy ] Installed at "D:\Python311\Lib\site-packages\kivy\__init__.py" [INFO ] [Python ] v3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "D:\Python311\python.exe" [INFO ] [Logger ] Purge log fired. Processing... [INFO ] [Logger ] Purge finished! [INFO ] [KivyMD ] 1.1.1, git-Unknown, 2023-06-16 (installed at "D:\Python311\Lib\site-packages\kivymd\__init__.py") [INFO ] [Factory ] 190 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [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 531.79'> [INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'> [INFO ] [GL ] OpenGL renderer <b'NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2'> [INFO ] [GL ] OpenGL parsed version: 4, 6 [INFO ] [GL ] Shading version <b'4.60 NVIDIA'> [INFO ] [GL ] Texture max size <32768> [INFO ] [GL ] Texture max units <32> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard allowed, single mode, docked[/output] RE: Error when running kivy on python - deanhystad - Jun-16-2023 More indentation errors. In Python, indenting serves the same purpose as {} in C. It creates blocks of code. If your code was written using {} for blocking, it would look like this: from kivy.config import Config Config.set('kivy','keyboard_mode','systemanddock') from kivymd.app import MDApp from kivy_garden.mapview import MapView class MyApp(MDApp): { def build(self): { mapview = MapView(zoom=10, Lat=36, Lon=-115) return mapview if __name__ == '__main__': { MyApp().run() } } }Maybe this makes it easier to see that your code does not make any MyApp objects. The only code that makes a MyApp object is deeply embedded in the build method of the MyApp class. Also, your indenting is all over the place. Convention is every indent level is 4 spaces deeper than the previous level. Maybe you should work through some kivy totorials. You cannot have success if you don't understand your tools. RE: Error when running kivy on python - janeik - Jun-16-2023 (Jun-16-2023, 09:54 PM)deanhystad Wrote: More indentation errors. Thanks for input. You are right. I just thought I should try an example from a youtube video before I dived into more suitable beginner levels. Was not even aware of the indenting. I will start with Python then Kivy and hopefully end up handling maps, Thanks for help and see You later. Regards |