Issue while hosting the dash on apache using mod_wsgi
wsgi file
import sys
sys.path.insert(0, “D:/Dashboard_Workspace/code_base/app_server”)
from myapp import server as app
application = app
Anyone faced such issue with apache hosting ?
Issue while hosting the dash on apache using mod_wsgi
wsgi file
import sys
sys.path.insert(0, “D:/Dashboard_Workspace/code_base/app_server”)
from myapp import server as app
application = app
Anyone faced such issue with apache hosting ?
I’ve used mod_wsgi for running dash apps before just fine without seeing this error. Have you tried running your same app with the default builtin server?
Yes I have tried the same app on default server, working fine (on the localhost)
eg : python myapp.py
After hosted on the apache 2.4 using mod_wsgi, throwing such weird error.
import sys
sys.path.insert(0, “D:/Dashboard_Workspace/code_base/app_server”)
from myapp import server as app
application = app
import dash
app = dash.Dash(“dashboard”)
server = app.server
app.layout = html.Div([
create_header(),
create_links(),
html.Div(id=‘page-content’),
])
@app.callback(Output(‘page-content’, ‘children’),
[Input(‘url’, ‘pathname’)])
def display_page(pathname):
if pathname == ‘/svn’:
return svn_analytics.layout
elif pathname ==’/build’:
return build_analytics.layout
elif pathname == ‘/readme’:
return create_readme()
elif pathname == ‘/clear-cache’:
cache.clear()
if name == ‘main’:
app.run_server(debug=True, host=‘0.0.0.0’, port=8082, threaded=True)
I can run your code without that issue using mod_wsgi-express
. I am however running it on a linux environment, so there could be some relevant difference there.
One suggestion is to try using app = dash.Dash(__name__)
. Getting the name
parameter correct is important for locating static files correctly, however I think that’s only relevant for adding custom static files in addition to the internal Dash ones, so it’s potentially a long shot, but worth a try.
Thanks Ned,
I am running it on windows 10 OS using mod_wsgi 4.5.24 & python 3.6
will try with the mod_wsgi-express, thanks for updates
getting excpetion in the js files, not sure from where it gets loaded
I didn’t noticed any such path in python site-packages
http://localhost:8082/_dash-component-suites/dash_renderer/react-dom@15.4.2.min.js?v=0.11.3
That is one of the JavaScript libraries Dash uses for the interface. It looks like you’re set these to use local copies (ie you’ve set app.scripts.config.serve_locally = True
. Do you get the same behaviour when you remove that and scripts are then sourced from the CDN?
It could also be worth checking that you’re using all the latest version of the various Dash Python packages. (dash
, dash-core-components
, dash-html-components
, dash-renderer
)
@chriddyp Do you have any suggestions as to what might be going on?
These are all good suggestions. I’d also recommend checking the network panel to see if the requests are getting made correctly.
I have set it to False,
app.config.suppress_callback_exceptions = False
app.css.config.serve_locally = False
app.scripts.config.serve_locally = False
All dash libraries (dash, dash-core-components, dash-html-components, dash-renderer) are upgraded.
And the problem persists?
If so, could you post a screenshot of the network panel of the developer tools that shows a request for that JavaScript file?
Hi,
I’m not sure of what I say, but could it be related to apache? What is your apache conf for this site ?
Hi,
I am using apache 2.4 with mod_wsgi
LoadModule wsgi_module “mod_wsgi.cp36-win32.pyd”
I tried it on both windows 10 & ubuntu 16.04, same issue
And what is in your /etc/apache2/sites-available/.conf (in linux, for window I don’t know where it is)?
It’s wsgi file in which used the WsgiScriptAlias pointed to the wsgi.py file
I’m afraid I’m out of suggestions also
Hi.
I do not know neither.
Maybe this can help, here is my configuration to run dash under mod_wsgi:
apache conf in /etc/apache2/sites-available/test.conf
<VirtualHost *:80>
ServerName localhost.dash
WSGIDaemonProcess dash_app user=www-data group=www-data threads=5 python-home=/var/www/apli_dash/venv
WSGIProcessGroup dash_app
WSGIScriptAlias / /var/www/test/wsgi.py
</VirtualHost>
python-home is for virtualenv setting.
And the wsgi.py file:
import sys
sys.path.insert(0, "/var/www/test")
from test import app
server = app.server
application = server
where test is the filename of the app.
With this skeleton, it works fine for me.
Python 3.5.3
libapache2-mod-wsgi-py3 : 4.5.11-1
import sys
#Expand Python classes path with your app’s path
sys.path.insert(0, “D:/Dashboard_Workspace/code_base/app_server”)
from index import server as app
#Put logging code (and imports) here …
#Initialize WSGI app object
application = app
<Directory D:/Dashboard_Workspace/My-DB-Latest-app/dashboard_code/app_server>
#Order allow,deny
#Allow from all
Require all granted
WSGIScriptAlias / D:/Dashboard_Workspace/My-DB-Latest-app/dashboard_code/app_server/dashboard.wsgi
Hi all,
Recently I am trying to deploy Dash in Apache2 WSGI mode (with libapache2-mod-wsgi). But I have the following error:
Traceback (most recent call last):
File “/home/azureuser/dash-sample-apps/apps/dash-financial-report/config.wsgi”, line 5, in
import app
File “/home/azureuser/dash-sample-apps/apps/dash-financial-report/app.py”, line 2, in
import dash
File “/usr/local/lib/python3.5/dist-packages/dash/init.py”, line 1, in
from .dash import Dash, no_update # noqa: F401
File “/usr/local/lib/python3.5/dist-packages/dash/dash.py”, line 18, in
import flask
ImportError: No module named ‘flask’
It seems that Flask could not be found within Dash library… If I execute python3 app.py, it can start Dash server in development mode without a problem. What is missing?