I will admit I never used gunicorn
before. When I run the command gunicorn main:app -k uvicorn.workers.UvicornWorker
gives error:
Error: class uri 'uvicorn.workers.UvicornWorker' invalid or not found:
[Traceback (most recent call last):
File "/Users/AdnanAhmad/Data/anaconda3/lib/python3.7/site-packages/gunicorn/util.py", line 135, in load_class
mod = import_module('.'.join(components))
File "/Users/X/Data/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'uvicorn'
uvicorn
andgunicorn
are installed as I am already able to useuvicorn main:app --reload
– Ramawhich gunicorn
and turns out is not using the one in myvenv
which sounds strange rather the one in host machine. What should I do? – Ramagunicorn
is available at the beginning of yourPATH
. Uninstall it then make sure it's properly installed and accessible on your venv. (And make sure you are actually using the venv.) – Overniceconda
. – Ramaenv/bin/gunicorn main:app -k uvicorn.workers.UvicornWorker
if your env folder is in the root of your project – Arbitrationapt-get
, it did not work. then I didconda install gunicorn
again, this time it installed in my current conda env and it started working. – Paulusgunicorn
I was still getting the missinguvicorn
issue. Then I found uvicorn was not installed under my current conda env. so I installed it:conda install -c conda-forge uvicorn
– Paulus