python kivy NameError: name '_name_' is not defined

from kivy.app import App

class MyApp(App):
    pass

if _name_ == "_main_":
    MyApp().run()

NameError: name '_name_' is not defined

This error appears both with single and double quotes

Upvotes: 0

Views: 851

Answers (1)

SEYED BABAK ASHRAFI
SEYED BABAK ASHRAFI

Reputation: 4271

You should use if __name__ == "__main__": for running a python file. __name__ is predefined in python core and you should use exactly that syntax in your code.

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

Upvotes: 1

Related Questions