I have a strange issue. I am migrating to gunicorn. I managed to migrate one project. It runs well. But I failed to migrate the second project. I put the Hello World Dash app that just has one HTML tag. The same error. Then I took the project that I have already successfully migrated. Still the same error message. This suggests that this issue is not an issue with the code. It may be be the issue with the version of Dash, Plotly or other modules. I created a virtual folder where I have installed the latest versions of modules required to run the project. The issue persists.
Any idea what it may be?
Another indirect evidence that this is an issue with the module versions is that the error is with the ‘require’ keyword. The ‘require’ keyword is run on the server side only. Thanks for pointing at the solution. I spent already a week trying to figure out a solution. I also tried various things like sys.path.addsitedir, both True/False for app.scripts.config.serve_locally
That does sound odd. This issue looks like its associated with running/loading the JavaScript modules, which makes the symptom you’re seeing more of a client-side issue, rather than a server side one. Though the root cause could well be with a server-side configuration problem.
Have you looked in the network tab of the dev tools to see if there’s any issues with the requests to retrieve the JavaScript assets?
if not, as a sanity check, I’d suggest trying the app in a fresh browser profile/private browsing mode, to check that it’s not some kind of weird caching issue.
Indeed, the issue looks very odd to me. The same code doesn’t run well in a different location.
Running in the fresh browser still gives the same error message. Network tab doesn’t show missing files. Again, the keyword ‘require’ is not supported by browsers. It is the Node.js thing.
I don’t know what to do. I checked a million times the nginx settings. They are good too.
No, I can use the external css. The issue was with the __ name __ present in the Dash class constructor. It worked now after removing __ name __ from the Dash class constructor. No idea why it created the issue.
But after removing the __ name __, the new issue appeared. The stylesheets in the assets folder aren’t served anymore. So I need to fix that __ name __ issue.
What fixed that person’s issue was to do a fresh install of everything.
It is possible that you are missing a key element. Or library. Make sure your requirements is up to date. If you are using something like pyodbc in Linux, you’ll need to add a couple of things to make it work as well.
Also, the main thing just keeps it from running twice since gunicorn actually runs your server from the server. At least I think so.
Yes, you are right. I may be missing something installed. Although I must say I reinstalled everything a few times and properly tested. But I found a solution. Imperfect but it works.
Because the issue is with that __ name __ parameter, I skip it in the class constructor. As a consequence the local stylesheet and javascript files are not recognized by the app. So I add them to the constructor like below,