Why won't my application run with uWSGI?

I am trying to create my first Dash app and using this tutorial from DigitalOcean for a walkthrough on how to setup uWSGI and Nginx which has resulted in the following code:

from dash import Dash, html, dcc
import plotly.express as px
import pandas as pd

app = Dash()
server = app.server

df = pd.DataFrame({
    "Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
    "Amount": [4, 1, 2, 2, 4, 5],
    "City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})

fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for your data.
    '''),

    dcc.Graph(
        id='example-graph',
        figure=fig
    )
])

if __name__ == '__main__':
    app.run_server(port=8080)

wsgi.py

from app import app as application

if __name__ == '__main__':
    application.run()

And I am running the application from within the src folder with the following terminal command:

uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi:app

Which results in the following output:

*** Starting uWSGI 2.0.20 (64bit) on [Sun Aug 28 18:13:05 2022] *** compiled with version: 8.5.0 20210514 (Red Hat 8.5.0-10) on 28 August 2022 21:47:33 os: Linux-4.18.0-372.19.1.el8_6.x86_64 #1 SMP Tue Aug 2 16:19:42 UTC 2022 nodename: localhost.localdomain machine: x86_64 clock source: unix detected number of CPU cores: 8 current working directory: /home/user/Documents/macro-dashboard/src detected binary path: /usr/libexec/platform-python3.6 !!! no internal routing support, rebuild with pcre support !!! *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 61480 your memory page size is 4096 bytes detected max file descriptor number: 262144 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to TCP address 0.0.0.0:8080 fd 5 Python version: 3.6.8 (default, Apr 12 2022, 06:55:39) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)] — Python VM already initialized — *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0x55a1692792e0 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 72904 bytes (71 KB) for 1 cores *** Operational MODE: single process *** unable to load app 0 (mountpoint=‘’) (callable not found or import error) *** no app loaded. going in full dynamic mode *** *** uWSGI is running in multiple interpreter mode *** spawned uWSGI worker 1 (and the only) (pid: 12532, cores: 1)

When I visit the url (http://0.0.0.0:8080/) in my local browser, I see the following output within terminal.

— no python application found, check your startup logs for errors — [pid: 12532|app: -1|req: -1/1] 127.0.0.1 () {36 vars in 1018 bytes} [Sun Aug 28 18:14:40 2022] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

I read through this thread and made the changes seen above. However, I am still seeing my error. What steps am I completing incorrectly that is showing the error? I Keep adjusting my application setup to try and have it identify the application but have been unsuccessful.

If there is anything I can add regarding additional details, please let me know. Thank you all for your time - I truly appreciate it.

try changing the wsgi.py

from app import app

application = app.server

and then try

uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi:application
1 Like