Import works on console with virtualenv activated, but not on web app


I'm able to import the package dash from the console with my virtualenv active.

(env1) 13:28 ~ $ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dash

However, when I when launching my web app I get import error

2017-07-16 13:36:55,275: Error running WSGI application
2017-07-16 13:36:55,293: ImportError: No module named dash
2017-07-16 13:36:55,293:   File "/var/www/", line 120, in <module>
2017-07-16 13:36:55,293:     from analysis_dash import app as application
2017-07-16 13:36:55,293: 
2017-07-16 13:36:55,293:   File "/home/Sherm4nLC/hello_pdash/", line 2, in <module>
2017-07-16 13:36:55,293:     import dash

Virtualenv was added to the Web App config Dashboard >>>

Virtualenv: Use a virtualenv to get different versions of flask, django etc from our default system ones. More info here. You need to Reload your web app to activate it; NB - will do nothing if the virtualenv does not exist. /home/Sherm4nLC/env1

Any ideas?

are you still seeing problems? your site seems to be loading without errors just now...

Hi, thanks for reaching out. I'm still experiencing the same error, I left momentarily a dummy flask site running, but I reversed it so you can check the error. I could be wrong, but I think it's not my config, thanks in advance.

Now I see your current problem is

TypeError: 'Dash' object is not callable

I see other people suffering from the same problem here. Looking at the dash documentation on deployment I see that the "app" variable (the instance of a Dash object) is not actually a wsgi application. you need to use app.server as your wsgi application.

so, eg, in your wsgi file, something like this:

from analysis_dash import app
application = app.server

Excellent, I just needed to change that line on the WSGI file. Thanks a lot Harry

hooray! hope some other people see this and find it useful :)

So could someone post an example wsgi file suitable for dash. Thanks.

If you look in your file, there will be an application variable. You need to make that application variable what harry posted above.

from yourwebappmodule import app
application = app.server

Thanks, Conrad. Now its clear to me.


Thank you Glenn Jones. I did a pip upgrade and apparently I did have a version mismatch problem.

Glenn Jones: The only things I can think of might be that you haven't configured plotly (though I don't know if that's necessary) or you may have a version mismatch between plotly and dash.

Karl: Don't know if you can help with this but I'm still not quite there using Dash (plotly) ERROR LOG (says 'ERROR in app: Exception on / [GET]') Any ideas?