Python Forum
Error when running kivy on python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when running kivy on python
#1
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]
Reply
#2
Check your indent on the build function
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
(Jun-16-2023, 01:34 PM)menator01 Wrote: Check your indent on the build function
Thanks. 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.
Error:
C:\Users\jan-e>python d:\mapfiler\map.py [INFO ] [Logger ] Record log in C:\Users\jan-e\.kivy\logs\kivy_23-06-16_3.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! Traceback (most recent call last): File "d:\mapfiler\map.py", line 4, in <module> from kivymd.app import MDApp ModuleNotFoundError: No module named 'kivymd'
Reply
#4
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?
janeik likes this post
Reply
#5
(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.

When you type "pip list" in a command shell, does it list 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:
Error:
File "d:\mapfiler\map.py", line 16 MapViewApp().run() ^ IndentationError: unindent does not match any outer indentation level
Reply
#6
(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.

When you type "pip list" in a command shell, does it list 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:
Error:
C:\Users\jan-e>python d:\mapfiler\map.py [INFO ] [Logger ] Record log in C:\Users\jan-e\.kivy\logs\kivy_23-06-16_21.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 not allowed, single mode, not docked Traceback (most recent call last): File "kivy\_event.pyx", line 235, in kivy._event.EventDispatcher.__init__ TypeError: object.__init__() takes exactly one argument (the instance to initialize) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "d:\mapfiler\map.py", line 16, in <module> MyApp().run() File "D:\Python311\Lib\site-packages\kivy\app.py", line 955, in run self._run_prepare() File "D:\Python311\Lib\site-packages\kivy\app.py", line 925, in _run_prepare root = self.build() ^^^^^^^^^^^^ File "d:\mapfiler\map.py", line 14, in build mapview = MapView(zoom=10, Lat=36, Lon=-115) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python311\Lib\site-packages\kivy_garden\mapview\view.py", line 560, in __init__ super().__init__(**kwargs) File "D:\Python311\Lib\site-packages\kivy\uix\widget.py", line 357, in __init__ super(Widget, self).__init__(**kwargs) File "kivy\_event.pyx", line 238, in kivy._event.EventDispatcher.__init__ TypeError: Properties ['Lat', 'Lon'] passed to __init__ may not be existing property names. Valid properties are ['_pause', '_zoom', 'animation_duration', 'background_color', 'bbox', 'cache_dir', 'center', 'center_x', 'center_y', 'children', 'cls', 'delta_x', 'delta_y', 'disabled', 'double_tap_zoom', 'height', 'ids', 'lat', 'lon', 'map_source', 'motion_filter', 'opacity', 'parent', 'pause_on_action', 'pos', 'pos_hint', 'right', 'size', 'size_hint', 'size_hint_max', 'size_hint_max_x', 'size_hint_max_y', 'size_hint_min', 'size_hint_min_x', 'size_hint_min_y', 'size_hint_x', 'size_hint_y', 'snap_to_zoom', 'top', 'width', 'x', 'y', 'zoom'] C:\Users\jan-e>
Reply
#7
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]
Reply
#8
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.
janeik likes this post
Reply
#9
(Jun-16-2023, 09:54 PM)deanhystad Wrote: 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.

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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error "cannot identify image file" part way through running hatflyer 0 683 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Getting error when running "MINUS" between 2 databases marlonbown 4 1,279 Nov-10-2022, 05:49 AM
Last Post: deanhystad
  Error while running code on VSC maiya 4 3,777 Jul-01-2022, 02:51 PM
Last Post: maiya
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,375 Jun-18-2022, 01:09 PM
Last Post: snippsat
  Error when running a matplot lib example aurelius_nero 3 6,915 Apr-24-2022, 01:24 PM
Last Post: Axel_Erfurt
  Keep getting Session management error when running imshow in pycharm pace 0 2,103 Mar-25-2021, 10:06 AM
Last Post: pace
  Error when running script on startup in Linux NoahTheNerd 0 1,975 Mar-07-2021, 04:54 PM
Last Post: NoahTheNerd
  Error when running mktorrent subprocess command pythonnewbie138 4 3,880 Sep-16-2020, 01:55 AM
Last Post: pythonnewbie138
  error while running in debug mode ModuleNotFoundError avipy123 0 2,639 Jul-14-2020, 02:05 PM
Last Post: avipy123
  Generate RPM package from a Python + Kivy application for an "offline" installation pruvosim 2 2,227 Jun-04-2020, 12:16 PM
Last Post: pruvosim

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020