superset icon indicating copy to clipboard operation
superset copied to clipboard

gunicorn cant find create_app()

Open blcksrx opened this issue 6 years ago • 33 comments

gunicorn cant find create_app()

 gunicorn -b 0.0.0.0:6666 "superset.app:create_app()"
[2019-12-09 19:14:22 +0330] [23027] [INFO] Starting gunicorn 19.9.0
[2019-12-09 19:14:22 +0330] [23027] [INFO] Listening at: http://0.0.0.0:6666 (23027)
[2019-12-09 19:14:22 +0330] [23027] [INFO] Using worker: sync
[2019-12-09 19:14:22 +0330] [23031] [INFO] Booting worker with pid: 23031
Loaded your LOCAL configuration at [/home/superset/superset_config.py]
2019-12-09 19:14:24,395:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 362, in import_app
    app = eval(obj, vars(mod))
  File "<string>", line 1, in <module>
NameError: name 'create_app' is not defined
Failed to find application object 'create_app()' in 'superset.app'
[2019-12-09 19:14:25 +0330] [23031] [INFO] Worker exiting (pid: 23031)
[2019-12-09 19:14:26 +0330] [23027] [INFO] Shutting down: Master
[2019-12-09 19:14:26 +0330] [23027] [INFO] Reason: App failed to load.

Expected results

what you expected to happen.

Actual results

what actually happens.

Screenshots

If applicable, add screenshots to help explain your problem.

How to reproduce the bug

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Environment

(please complete the following information):

  • superset version: superset version
  • python version: python --version
  • node.js version: node -v
  • npm version: npm -v

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • [ ] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [ ] I have reproduced the issue with at least the latest released version of superset.
  • [ ] I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

Add any other context about the problem here.

blcksrx avatar Dec 09 '19 15:12 blcksrx

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.88. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Dec 09 '19 15:12 issue-label-bot[bot]

Hi @blcksrx, can you please add the superset version your using?

dpgaspar avatar Dec 09 '19 16:12 dpgaspar

Hi @blcksrx, can you please add the superset version your using?

Master branch, I cloned it about an hour ago

blcksrx avatar Dec 09 '19 17:12 blcksrx

@blcksrx - Take a look here: https://github.com/apache/incubator-superset/blob/master/CONTRIBUTING.md#sql-lab-async

Celery needs a pointer to the actual "celery instance": celery worker --app=superset.tasks.celery_app:app -Ofair

craig-rueda avatar Dec 09 '19 17:12 craig-rueda

@blcksrx - Take a look here: https://github.com/apache/incubator-superset/blob/master/CONTRIBUTING.md#sql-lab-async

Celery needs a pointer to the actual "celery instance": celery worker --app=superset.tasks.celery_app:app -Ofair

Its not about celery worker or celery beat. Its about running webserver with gunicorn

blcksrx avatar Dec 09 '19 18:12 blcksrx

Oops, didn't see that. I would second @dpgaspar's concern about not being up to date. After pulling latest, did you re-pip? It's possible that you're still pointing at something old in your site-packages...

craig-rueda avatar Dec 09 '19 19:12 craig-rueda

Ofcourse yes. I did it

blcksrx avatar Dec 09 '19 19:12 blcksrx

Sorry it's not clear to me, is it solved?

dpgaspar avatar Dec 10 '19 09:12 dpgaspar

No, its not solved yet

blcksrx avatar Dec 10 '19 09:12 blcksrx

I'm not able to replicate the problem, can you please create a clean/new virtualenv and reinstall superset and dependencies, then test and report back. If the problem persists, give us all commands you went through and output

dpgaspar avatar Dec 10 '19 16:12 dpgaspar

Same error happened to me. Versions: Superset 0.35.1 Python 3.6.8 Flask 1.1.1 Werkzeug 0.16.0

followed setup instructions from official apache-superset "installation how-to" except that I did not created a virtualenv. All other steps done as how-to stated.

miquel-simo avatar Dec 14 '19 21:12 miquel-simo

same here, ubuntu 18.04.3 followed the installation instructions and also created virtualenv:

NameError: name 'create_app' is not defined Failed to find application object 'create_app()' in 'superset.app' [2019-12-14 23:22:23 +0100] [3352] [INFO] Worker exiting (pid: 3352) Traceback (most recent call last): File "/root/venv/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app app = eval(obj, vars(mod)) File "", line 1, in NameError: name 'create_app' is not defined Failed to find application object 'create_app()' in 'superset.app' [2019-12-14 23:22:23 +0100] [3350] [INFO] Worker exiting (pid: 3350) [2019-12-14 23:22:24 +0100] [3336] [INFO] Shutting down: Master [2019-12-14 23:22:24 +0100] [3336] [INFO] Reason: App failed to load.

facePlanted avatar Dec 14 '19 22:12 facePlanted

This is starting to make a bit of sense. The docs are for master, whereas 0.35 still does things the old way. Try 'superset.app' instead of 'superset.app:create_app()'.

After the next release, things should be consistent.

craig-rueda avatar Dec 15 '19 01:12 craig-rueda

(venv) root@mike5:~# gunicorn -w 2 -k gevent --timeout 120 -b 0.0.0.0:6666 --limit-request-line 0 --limit-request-field_size 0 --statsd-host localhost:8125 'superset.app' [2019-12-15 07:06:54 +0100] [17640] [INFO] Starting gunicorn 19.8.1 [2019-12-15 07:06:54 +0100] [17640] [INFO] Listening at: http://0.0.0.0:6666 (17640) [2019-12-15 07:06:54 +0100] [17640] [INFO] Using worker: gevent [2019-12-15 07:06:54 +0100] [17643] [INFO] Booting worker with pid: 17643 [2019-12-15 07:06:54 +0100] [17644] [INFO] Booting worker with pid: 17644 2019-12-15 07:06:55,908:INFO:root:logging was configured successfully 2019-12-15 07:06:55,961:INFO:root:logging was configured successfully 2019-12-15 07:06:56,029:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'> 2019-12-15 07:06:56,081:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'> Traceback (most recent call last): File "/root/venv/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app app = eval(obj, vars(mod)) File "", line 1, in NameError: name 'application' is not defined Failed to find application object 'application' in 'superset.app' [2019-12-15 07:06:57 +0100] [17644] [INFO] Worker exiting (pid: 17644) Traceback (most recent call last): File "/root/venv/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app app = eval(obj, vars(mod)) File "", line 1, in NameError: name 'application' is not defined Failed to find application object 'application' in 'superset.app' [2019-12-15 07:06:57 +0100] [17643] [INFO] Worker exiting (pid: 17643) [2019-12-15 07:06:57 +0100] [17640] [INFO] Shutting down: Master [2019-12-15 07:06:57 +0100] [17640] [INFO] Reason: App failed to load.

facePlanted avatar Dec 15 '19 06:12 facePlanted

try with: superset:app

edge7 avatar Dec 15 '19 19:12 edge7

Confirmed. Works with superset.app

gunicorn -w 10 -k gevent --timeout 120 -b 0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 --statsd-host localhost:8125 superset:app

miquel-simo avatar Dec 15 '19 21:12 miquel-simo

Yes superset:app instead of superset.app fixed the issue, thank you

facePlanted avatar Dec 15 '19 23:12 facePlanted

If you look at the source code (0.35.1, you can see that the Flask App is defined in the superset module (in particular in init file---> superset:app In master it is defined in superset/app.py with a function named create_app

Agree that documentation should be improved

edge7 avatar Dec 16 '19 11:12 edge7

Agree that documentation should be improved

It's not that it should be improved. It just needs to be understood that the docs represent the master branch and not the pypi release.

metaperl avatar Dec 16 '19 18:12 metaperl

The docs are for master, whereas 0.35 still does things the old way.

The online docs have an install section that suggest that one can install and upgrade apache via pip: https://superset.incubator.apache.org/installation.html#upgrading

but the documentation suggesting this is generated from the git master not the pip release.

The building from source section of the docs is misleading. it says:

More advanced users may want to build Superset from sources.

This is incorrect: any user that wants Superset to behave the way to docs advertise would do this.

metaperl avatar Dec 16 '19 19:12 metaperl