kivy: ImportError:没有一个名为app的模块[复制]

时间:2022-04-11 23:16:05

This question already has an answer here:

这个问题已经有了答案:

I just installed Kivy by following the steps mentioned on the official documentation.

我只是按照官方文件中提到的步骤安装了Kivy。

So I tried to test if it works by running an example found on the official documentation:

所以我试着通过在官方文档中找到的一个例子来测试它是否有效:

import kivy

from kivy.app import App
from kivy.uix.label import Label   

class MyApp(App):

    def build(self):
        return Label(text='Hello world')


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

However, I got this error:

然而,我犯了一个错误:

begueradj@begueradj-hacker:~# python kivy.py 
Traceback (most recent call last):
  File "kivy.py", line 1, in <module>
    import kivy
  File "/root/kivy.py", line 3, in <module>
    from kivy.app import App
ImportError: No module named app

Installation went ok, so why is this problem ?

安装正常,为什么会出现这个问题?

1 个解决方案

#1


22  

You named your file kivy.py. Rename it to something else. You are importing from your file not the kivy package. Make sure to delete any .pyc file also.

你给你的文件命名为kiv .py。把它重命名为其他东西。您正在从您的文件导入,而不是kivy包。确保删除任何.pyc文件。

#1


22  

You named your file kivy.py. Rename it to something else. You are importing from your file not the kivy package. Make sure to delete any .pyc file also.

你给你的文件命名为kiv .py。把它重命名为其他东西。您正在从您的文件导入,而不是kivy包。确保删除任何.pyc文件。