kivy: ImportError: No module named app

user4772964 picture user4772964 · Apr 15, 2015 · Viewed 14.8k times · Source

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

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 ?

Answer

Padraic Cunningham picture Padraic Cunningham · Apr 15, 2015

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.