GibbsConsulting / django-plotly-dash

Expose plotly dash apps as django tags
MIT License
551 stars 125 forks source link

stuck at "loading" for demo 3,4,6,7,9 and also when rendering dash_pivottable compoment #360

Open luyi1678 opened 3 years ago

luyi1678 commented 3 years ago

Nice repo, but I'm struggling with it. I'm using pycharm on win10.

Message from terminal Below are what the terminal showed when this "loading" issue happened for various demos and my own app using dash_pivottable:

-For demo 4, File "G:\Envs\my_django_env\lib\site-packages\channels\routing.py", line 73, in call raise ValueError( ValueError: No application configured for scope type 'websocket' WebSocket DISCONNECT /ws/channel [127.0.0.1:53305]

-For demo 7: HTTP GET /django_plotly_dash/app/BootstrapApplication/_dash-component-suites/dash/dash-renderer/build/dash_renderer.v1_21_0m1629962921.min.js 404 [0.01, 127.0.0.1:62567]

-For demo 9: HTTP GET /django_plotly_dash/app/LocalState/_dash-component-suites/dash/dash-renderer/build/dash_renderer.v1_21_0m1629962921.min.js 404 [0.01, 127.0.0.1:56947]

-For dash-pivottable: HTTP GET /static/dash/component/dash_pivottable/dash_pivottable.min.js 404 [0.01, 127.0.0.1:61939]

my pip list Package Version


aioredis 1.3.1 asgiref 3.4.0 async-timeout 3.0.1 attrs 21.2.0 autobahn 21.3.1 Automat 20.2.0 backports.entry-points-selectable 1.1.0 beautifulsoup4 4.9.3 bootstrap4 0.1.0 Brotli 1.0.9 cffi 1.14.6 channels 3.0.4 channels-redis 3.3.0 click 8.0.1 colorama 0.4.4 constantly 15.1.0 cryptography 3.4.8 daphne 3.0.2 dash 1.21.0 dash-bootstrap-components 0.13.0 dash-core-components 1.17.1 dash-daq 0.5.0 dash-html-components 1.1.4 dash-pivottable 0.0.2 dash-renderer 1.9.1 dash-table 4.12.0 defusedxml 0.7.1 diff-match-patch 20200713 distlib 0.3.3 Django 3.2.4 django-bootstrap4 3.0.1 django-import-export 2.5.0 django-pandas 0.6.4 django-plotly-dash 1.6.5 django-redis 5.0.0 dpd-components 0.1.0 dpd-static-support 0.0.5 et-xmlfile 1.1.0 filelock 3.2.0 Flask 2.0.1 Flask-Compress 1.10.1 future 0.18.2 hiredis 2.0.0 hyperlink 21.0.0 idna 3.2 incremental 21.3.0 itsdangerous 2.0.1 Jinja2 3.0.1 MarkupPy 1.14 MarkupSafe 2.0.1 msgpack 1.0.2 numpy 1.21.2 odfpy 1.4.1 openpyxl 3.0.7 pandas 1.3.2 pip 21.1.3 platformdirs 2.4.0 plotly 5.2.2 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycparser 2.20 pyOpenSSL 20.0.1 python-dateutil 2.8.2 pytz 2021.1 PyYAML 5.4.1 redis 3.5.3 service-identity 21.1.0 setuptools 57.0.0 six 1.16.0 soupsieve 2.2.1 sqlparse 0.4.1 tablib 3.0.0 tenacity 8.0.1 Twisted 21.7.0 twisted-iocpsupport 1.0.1 txaio 21.2.1 typing-extensions 3.10.0.2 virtualenv 20.8.1 Werkzeug 2.0.1 wheel 0.36.2 whitenoise 5.3.0 xlrd 2.0.1 xlwt 1.3.0 zope.interface 5.4.0

my accidental findings I noted that it was said this is most likely because of the versions of channels package in some other related issues, so I executed the "make_env" file in git bash to create a new env, in which the version of channels is 2.4.0. However, when I run server this time, another error was raised:

File "G:\mygithub\django-plotly-dash\demo\demo\asgi.py", line 35, in "http": AsgiHandler(), TypeError: init() missing 1 required positional argument: 'scope'

**This error disappear after I commented out 'channels' in the list of "INSTALLED APPS" in settings file, but if I run the server by "python manage.py runserver" in pycharm, those pages mentioned above are all stuck and showing "loading".

However, I finally found that if I run the server using the code of "python manage.py runserver --nostatic", then problems solved.

Although I found the solution while I'm writing this issue reporting, I still want to know why is that and channels seems useless here for that I commented it out, otherwise I will have the strange error of missing positional argument.**

Package Version Location


aioredis 1.3.1 alabaster 0.7.12 asgiref 3.4.1 astroid 2.8.0 async-timeout 3.0.1 atomicwrites 1.4.0 attrs 19.3.0 autobahn 21.3.1 Automat 20.2.0 Babel 2.9.1 beautifulsoup4 4.10.0 bleach 4.1.0 Brotli 1.0.9 certifi 2021.5.30 cffi 1.14.6 channels 2.4.0 channels-redis 3.3.1 charset-normalizer 2.0.6 click 8.0.1 colorama 0.4.4 constantly 15.1.0 coverage 5.5 coveralls 3.2.0 cryptography 35.0.0 daphne 2.5.0 dash 1.20.0 dash-bootstrap-components 0.13.1 dash-core-components 1.16.0 dash-html-components 1.1.3 dash-renderer 1.9.1 dash-table 4.11.3 Django 3.2.7 django-bootstrap4 3.0.1 django-plotly-dash 1.6.5 g:\mygithub\django-plotly-dash django-redis 5.0.0 docopt 0.6.2 docutils 0.17.1 dpd-components 0.1.0 dpd-static-support 0.0.5 Flask 2.0.1 Flask-Compress 1.10.1 future 0.18.2 grip 4.5.2 hiredis 2.0.0 hyperlink 21.0.0 idna 3.2 imagesize 1.2.0 importlib-metadata 4.8.1 incremental 21.3.0 iniconfig 1.1.1 isort 5.9.3 itsdangerous 2.0.1 Jinja2 3.0.1 keyring 23.2.1 lazy-object-proxy 1.6.0 livereload 2.6.3 Markdown 3.3.4 MarkupSafe 2.0.1 mccabe 0.6.1 msgpack 1.0.2 numpy 1.21.2 packaging 21.0 pandas 1.3.3 path-and-address 2.0.1 pip 21.2.4 pkginfo 1.7.1 platformdirs 2.4.0 plotly 5.3.1 pluggy 1.0.0 py 1.10.0 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycparser 2.20 Pygments 2.10.0 pylint 2.11.1 pyOpenSSL 21.0.0 pyparsing 2.4.7 pytest 6.2.5 pytest-cov 2.12.1 pytest-django 4.4.0 python-coveralls 2.9.3 python-dateutil 2.8.2 pytz 2021.3 pywin32-ctypes 0.2.0 PyYAML 5.4.1 readme-renderer 30.0 redis 3.5.3 requests 2.26.0 requests-toolbelt 0.9.1 rfc3986 1.5.0 service-identity 21.1.0 setuptools 58.1.0 six 1.16.0 snowballstemmer 2.1.0 soupsieve 2.2.1 Sphinx 4.2.0 sphinx-autobuild 2021.3.14 sphinx-rtd-theme 1.0.0 sphinxcontrib-applehelp 1.0.2 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.5 sqlparse 0.4.2 tenacity 8.0.1 toml 0.10.2 tornado 6.1 tqdm 4.62.3 twine 3.4.2 Twisted 21.7.0 twisted-iocpsupport 1.0.2 txaio 21.2.1 typing-extensions 3.10.0.2 urllib3 1.26.7 webencodings 0.5.1 Werkzeug 2.0.1 wheel 0.37.0 whitenoise 5.3.0 wrapt 1.12.1 zipp 3.6.0 zope.interface 5.4.0

delsim commented 3 years ago

@luyi1678 what happens if you use a version of Dash < 1.21 as well as the 2.4.0 version of channels? As per #349 there are outstanding issues with version 1.21 onwards

luyi1678 commented 3 years ago

@luyi1678 what happens if you use a version of Dash < 1.21 as well as the 2.4.0 version of channels? As per #349 there are outstanding issues with version 1.21 onwards

Hi delsim, actually, I've tested what you mentioned already, which I described in the section "my accidental findings" above.

" when I run server this time, another error was raised:

File "G:\mygithub\django-plotly-dash\demo\demo\asgi.py", line 35, in "http": AsgiHandler(), TypeError: init() missing 1 required positional argument: 'scope'

**This error disappear after I commented out 'channels' in the list of "INSTALLED APPS" in settings file, but if I run the server by "python manage.py runserver" in pycharm, those pages mentioned above are all stuck and showing "loading".

However, I finally found that if I run the server using the code of "python manage.py runserver --nostatic", then problems solved. "

GibbsConsulting commented 3 years ago

Just trying to work through your last statement. Is the environment constant between the different situations? In particular, when you run with '--nostatic' is that with the same environment and settings that is giving the asgi error? Or with the same environment and settings that is sticking on 'loading'?

And what does 'problems solved' mean when serving with '--nostatic' -> is the app working, and are the static files being served at all? Can you validate this in the browser using devtools or similar?

luyi1678 commented 3 years ago

@GibbsConsulting sorry for a late reply.

This is what I got when using 'python manage.py runserver' image And the pivot table shows up successfully by using 'python manage.py runserver --nostatic' image

The environment is the same, and I commented out 'channels' for both cases, the only difference here is the magic '--nostatic'.

Please let me know if anything else needed for solving this mystery.

GibbsConsulting commented 3 years ago

Sorry, missed the obvious here. For the debug environment, you'll need the --nostatic flag to work with channels. See for example the flags in the demo script

In production, you'll need to make sure that static files are served appropriately, either by setting up your reverse proxy correctly or through using whitenoise or similar.