I’m trying to build a simple Dash app on Pythonanywhere but encountered errors that I don’t know how to fix. Thanks in advance!
File “app.py”:
from dash import Dash, html
dash_app = Dash()
dash_app.layout = [html.Div(children='Hello World')]
WSGI file:
import sys
# add your project directory to the sys.path
project_home = '/home/weiqizhang/mysite'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# import flask app but need to call it "application" for WSGI to work
from app import dash_app # noqa
application = dash_app.server
Here is the error log:
2024-06-08 04:10:49,581: Error running WSGI application
2024-06-08 04:10:49,581: dash.exceptions.NoLayoutException: Layout must be a dash component or a function that returns a dash component.
2024-06-08 04:10:49,581: File “/var/www/weiqizhang_pythonanywhere_com_wsgi.py”, line 16, in
2024-06-08 04:10:49,581: from app import dash_app # noqa
2024-06-08 04:10:49,582:
2024-06-08 04:10:49,582: File “/home/weiqizhang/mysite/app.py”, line 5, in
2024-06-08 04:10:49,582: dash_app.layout = [html.Div(children=‘Hello World’)]
2024-06-08 04:10:49,582:
2024-06-08 04:10:49,582: File “/usr/local/lib/python3.10/site-packages/dash/dash.py”, line 551, in layout
2024-06-08 04:10:49,582: _validate.validate_layout_type(value)
2024-06-08 04:10:49,582:
2024-06-08 04:10:49,582: File “/usr/local/lib/python3.10/site-packages/dash/_validate.py”, line 383, in validate_layout_type
2024-06-08 04:10:49,583: raise exceptions.NoLayoutException(
2024-06-08 04:10:49,583: ***************************************************
2024-06-08 04:10:49,583: If you’re seeing an import error and don’t know why,
2024-06-08 04:10:49,583: we have a dedicated help page to help you debug:
2024-06-08 04:10:49,583: Debugging with sys.path / ImportError issues | PythonAnywhere help
2024-06-08 04:10:49,583: ***************************************************

