简体   繁体   English

为什么我在 python 中出现导入错误,当我安装了 pip 我的应用程序所需的每个模块时

[英]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问候 K1NG_C0D3R_AD0T

Use GridLayout, with a capital L使用 GridLayout,大写 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".您可以在错误消息中看到它无法导入“Gridlayout”,因为实际名称是“GridLayout”。 I think this will fix your issue.我认为这将解决您的问题。

Use this:用这个:

from kivy.uix.gridlayout import GridLayout

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我有 3.7 时“请升级 python”,当我有 20.0.2 时“请升级 pip”。 为什么我收到这个错误? - "Please upgrade python" when I have 3.7 and "Please upgrade pip" when I have 20.0.2. Why am I getting this error? 当我尝试将mwclient模块用于Python时,为什么会出现错误“无法导入名称扫描仪”? - Why am I getting the error “cannot import name Scanner” when I try to use the mwclient module for Python? 获取ImportError:运行Flask App时无法导入名称pformat。 我正在使用Python 2.7.13并安装了flask - Getting ImportError: cannot import name pformat when running Flask App. I am using Python 2.7.13 and have flask installed 如何在 python 中安装 plyer 库? 我已经安装了 plyer 模块,仍然收到“没有模块错误” - how to install plyer library in python? i have already installed plyer module , still am getting "no module error" 为什么在安装依赖项之前出现Tox导入错误 - why am i getting a tox import error before the dependencies are installed 为什么即使在我通过 pip 安装了模块后,还是会收到“没有名为 scipy 的模块”错误? - Why do I receive a “no module named scipy” error even after I have installed the module via pip? Pip已经安装:但我没有得到名为lxml的模块 - Pip is already installed: but I am getting no module named lxml 未找到模块错误,但我安装了模块 pip - Module not found error but I have pip installed the module 我已经在 spyder 上安装了“apiclient”,但是当我在 Python 中运行该程序时,为什么会出现错误“找不到模块错误” - I have installed "apiclient" to the spyder but why it gives the error "Module Not Found Error" when i run the program in Python 为什么我得到Tensorflow服务模块导入错误? - Why am I getting Tensorflow Serving module import error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM