Forums

Graphs generated by Python are not displayed when app deployed on PythonAnywhere despite working when running locally

I have used Dash to create a Flask app that I want to deploy using this site. I have built the app locally and everything works as it should but only when I run it on a local server. When I try to deploy on this site, the graphs that are generated by the app are not displayed - everything else seems to work as it should though.

Have you seen this problem before and do you have a solution?

Thanks,

Ciaran

Hi there,

What error do you see instead when the graphs are not displayed? I just followed this Dash tutorial and created this website using the code from the first example. You can take a look at my git repo here.

Hi,

I appreciate the quick reply. Yes, this is the same tutorial I followed and is how I got the first version of my app (cwelsh2.pythonanywhere.com) to work which follows your example fairly closely. I have now changed the app slightly to include multiple pages. I had no trouble deploying the first app but I have problems with the multi page app. You can see the problems by going to the app as I have the multi page app version active.

I didn't see the error at first as it got buried under other errors. After switching to the multi-app branch in bash, I made the appropriate modifications to the wsgi file and clicked the green 'reload' button. This takes a while and I get the message Your webapp took a long time to reload. It probably reloaded, but we were unable to check it. Then in the error log file I have:

2017-11-21 14:33:35,690: IOError: write error
2017-11-21 14:33:35,681: IOError: write error
2017-11-21 14:33:35,691: IOError: write error
2017-11-21 14:33:35,700: Error running WSGI application
2017-11-21 14:33:35,700: Error running WSGI application
2017-11-21 14:33:35,700: Error running WSGI application
2017-11-21 14:33:35,701: GeneratorExit
2017-11-21 14:33:35,702: IOError: write error
2017-11-21 14:33:35,702: Error running WSGI application
2017-11-21 14:33:35,703: GeneratorExit

Since my code worked as expected locally I suspect the problem lies somewhere within pythonanywhere. I suspect this will be hard for you to troubleshoot but any suggestions would be greatly received.

Cheers,

Just for additional info I've just made my repo temporarily public. The multipage app is on the master branch under /large_study. I have an app.py which initiates the flask server and an index.py which collects the apps from /large_study/apps.

When I go to cwelsh2.pythonanywhere.com, I notice that you have authentication turne don- could it be blocking the connection between your Dash server and your browser?

I forgot about the authentication. I've commented out those lines of code (so you should now be able to access) and repeated the procedure but the problem persists. I also get the same error message in the error log.

Hmm- I've updated my code (just by pasting in the code from your multipage app link) , and it seems to work.

I appreciate your effort. The app itself works (try http://cwelsh2.pythonanywhere.com/ again), i.e. the links and buttons operate however the graphs are not being displayed. The exact same code however works offline and generates the graphs

I see a bunch of charts on that page. Did you work out what the problem was?

Hi Glenn - unfortunately no. This is an older version of the code that I had to put back up for collaborators. I'm still trying to resolve the issue. My plan is to produce a single page app with lots of content rather than neatly breaking things down into multiple pages.

Then I would suggest looking at the developer tools in your browser to see what requests are being made and what the responses are. You can probably work back from there to find the problem.