I am trying to deploy Django application with ASGI server, I am following this tutorial(https://www.digitalocean.com/community/tutorials/how-to-set-up-an-asgi-django-app-with-postgres-nginx-and-uvicorn-on-ubuntu-20-04). When I run this command (gunicorn --bind 0.0.0.0:8000 myproject.asgi -w 4 -k uvicorn.workers.UvicornWorker). This is the error
Error: class uri ‘uvicorn.workers.UvicornWorker’ invalid or not found:
[Traceback (most recent call last): File “/home/sreekar/.local/lib/python3.8/site-packages/gunicorn/util.py”, line 99, in load_class mod = importlib.import_module(‘.’.join(components)) File “/usr/lib/python3.8/importlib/init.py”, line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “<frozen importlib._bootstrap>”, line 1014, in _gcd_import File “<frozen importlib._bootstrap>”, line 991, in _find_and_load File “<frozen importlib._bootstrap>”, line 961, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed File “<frozen importlib._bootstrap>”, line 1014, in _gcd_import File “<frozen importlib._bootstrap>”, line 991, in _find_and_load File “<frozen importlib._bootstrap>”, line 975, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 671, in _load_unlocked File “<frozen importlib._bootstrap_external>”, line 848, in exec_module File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed File “/home/sreekar/.local/lib/python3.8/site-packages/uvicorn/init.py”, line 1, in <module> from uvicorn.config import Config File “/home/sreekar/.local/lib/python3.8/site-packages/uvicorn/config.py”, line 35, in <module> from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware File “/home/sreekar/.local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py”, line 13, in <module> from asgiref.typing import ( ImportError: cannot import name ‘WebSocketScope’ from ‘asgiref.typing’ (/home/sreekar/.local/lib/python3.8/site-packages/asgiref/typing.py) ]
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hell,
When you executed the following command, did it complete successfully:
Also if you try to run the same command but with
uvicorn
does it work as normal:Best,
Bobby