The Biggest Python Trap!

If I had a Dollar for every hour I’ve wasted debugging this issue in Python, I’d be … uhh… well a little more well off than I am now.

The way that Python handles modules is fantastic, but sometimes if you don’t pay attention, you can end up wasting time debugging an issue when the error message leads you down the wrong path.

Often – and this blog is probably more a reminder for myself than anyone else – I create small test scripts to play around with new modules. In the most recent example, I started experimenting with Kivy – the Python UI library.

I created a script called “” and copied the hello world example code and ran it.

Traceback (most recent call last):
  File "", line 1, in <module>
    from import App
  File "C:\Python\hal\", line 1, in <module>
    from import App
ModuleNotFoundError: No module named ''; 'kivy' is not a package

Of course, the first thought is that the module was not properly installed. It could take some time (as is usually the case with me) to realize that the actual problem is that I named the test script ( the same as the module I am trying to import:

from import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Hello World')


Silly, silly mistake, but somehow I do this ALL THE TIME. I think it’s time to start naming my scripts “” or something 😀

Leave a Reply

Your email address will not be published. Required fields are marked *