Xuerivera
Xuerivera

Reputation: 71

The 'uvloop>=0.14.0' distribution was not found and is required by uvicorn

I'm new at learning FastAPI, and I'm getting stuck at the very beginning. I keep getting the following error:

(venv) root@Xue:/home/proyectos/FastAPI# uvicorn main.py:app --reload
Traceback (most recent call last):
  File "/usr/bin/uvicorn", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3254, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3237, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3266, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'uvloop>=0.14.0' distribution was not found and is required by uvicorn

this is my python code:

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def home():
    return {'Hello': 'World'}

I already try with pip install -U uvloop pip, pip install uvloop==0.14.0 and no fix.

Upvotes: 6

Views: 14154

Answers (5)

Max Anthony
Max Anthony

Reputation: 1

pip install uvicorn solved the issue for me.

Upvotes: 0

Jacob Solawetz
Jacob Solawetz

Reputation: 378

I fixed this issue by installing my Python requirements outside of my virtualenv on my root python

pip freeze > requirements.txt

deactivate

pip uninstall -r requirements.txt -y

Upvotes: 0

Ayushma
Ayushma

Reputation: 71

I tried running using the following command and this worked for me:

python -m uvicorn main:app --reload

here the main is your file name

Upvotes: 7

Arrun Prasaath
Arrun Prasaath

Reputation: 31

pip uninstall -r requirements.txt -y

and then install FastAPI using

pip install FastAPI[all]

Upvotes: 3

AidarDzhumagulov
AidarDzhumagulov

Reputation: 111

I had such a problem. First, activate your venv:

source venv/bin/activate

Freeze and safe pip list in requirements:

pip freeze > requirements.txt

Uninstall:

pip uninstall -r requirements.txt -y

Deactivate:

rm -r venv/

After this you have to remake venv:

python3 -m venv venv

And install all necessary files.

Upvotes: 0

Related Questions