benyrey
Posts: 67
Joined: Tue Aug 19, 2014 7:52 pm

Flask(_name_) error please

Sun Oct 05, 2014 5:16 pm

Hello world,

I installed flask ([email protected] ~ $ sudo pip install flask) but then I get
the following error:
app = Flask(_name_)
NameError: name '_name_' is not define
As usually I do not know what the heck to do.

Thanks a lot

Beny

DirkS
Posts: 10014
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Flask(_name_) error please

Sun Oct 05, 2014 5:37 pm

I think there should be 2 underscores before and after 'name':

Code: Select all

app = Flask(__name__)
Gr.
Dirk.

benyrey
Posts: 67
Joined: Tue Aug 19, 2014 7:52 pm

Re: Flask(_name_) error please

Sun Oct 05, 2014 6:02 pm

Thanks DirkS,

You're right: two underscore(s) before and after 'name'

I appreciate your support

Beny

kartik62
Posts: 1
Joined: Mon Mar 05, 2018 7:51 am

Re: Flask(_name_) error please

Mon Mar 05, 2018 7:57 am

i am still getting this same error even after editing it with double underscores before and after name.
can anyone please tell what is the error here.
Capture2.PNG
Capture2.PNG (3.5 KiB) Viewed 2461 times
Capture1.PNG
Capture1.PNG (4.11 KiB) Viewed 2461 times

squiregeek
Posts: 23
Joined: Mon Jan 14, 2013 3:44 pm

Re: Flask(_name_) error please

Tue Mar 06, 2018 5:03 pm

I'm fairly new with Flask, but you might consider adding if ___name == "__main__": before app.run(). Has to do with decorators which I'm still learning about.

I've run a couple of simple scripts that way without problems. Hope this helps.

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Flask(_name_) error please

Tue Mar 06, 2018 9:29 pm

Your error message still shows single underscores before and after name.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

Return to “Python”