简体   繁体   中英

Why am I getting the Import error in python, when I have pip installed every single module required for my App

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import Gridlayout
from kivy.uix.textinput import TextInput


class MyGrid(GridLayout):
    def __init__(self, **kwargs):
        super(MyGrid, self).__init__(**kwargs)
        self.cols = 2
        self.add_widget(Label(text="Name: "))
        self.name = TextInput(multiline=False)
        self.add_widget(self.name)
        



class MyApp(App):
    def build(self):
        return MyGrid()

if __name__ == "__main__":
    MyApp().run()

After running this I am getting the result this:

>>> 
= RESTART: C:\Users\skkar\Desktop\adi\Python Files\Telgram Bot\Python\App for Telegram Bot\Adot Telegrm Bot App.py
[INFO   ] [Logger      ] Record log in C:\Users\skkar\.kivy\logs\kivy_21-04-07_13.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.3.2
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO   ] [Kivy        ] v2.0.0
[INFO   ] [Kivy        ] Installed at "C:\Users\skkar\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\skkar\AppData\Local\Programs\Python\Python39\pythonw.exe"
[INFO   ] [Factory     ] 186 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
 Traceback (most recent call last):
   File "C:\Users\skkar\Desktop\adi\Python Files\Telgram Bot\Python\App for Telegram Bot\Adot Telegrm Bot App.py", line 4, in <module>`
     from kivy.uix.gridlayout import Gridlayout
 ImportError: cannot import name 'Gridlayout' from 'kivy.uix.gridlayout' (C:\Users\skkar\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\uix\gridlayout.py)

Why am I getting this? When ever I run it I get this only. And nothing else.

Please tell and help me with my code!

Regards K1NG_C0D3R_AD0T

Use GridLayout, with a capital L

from kivy.uix.gridlayout import GridLayout

You can see in the error message that it cannot import "Gridlayout" because the actual name is "GridLayout". I think this will fix your issue.

Use this:

from kivy.uix.gridlayout import GridLayout

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM