The Error:
Command Used to Run:
C:\Users\super\Desktop\Work\Charges2> uvicorn main:app --reload
Console Status:
PS C:\Users\super\Desktop\Work\Charges2> uvicorn main:app --reload
INFO: Will watch for changes in these directories: ['C:\\Users\\super\\Desktop\\Work\\Charges2']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL C to quit)
INFO: Started reloader process [69628] using statreload
WARNING: The --reload flag should not be used in production on Windows.
INFO: Started server process [72184]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:61648 - "GET / HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 364, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\fastapi\applications.py", line 212, in __call__
await super().__call__(scope, receive, send)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\applications.py", line 119, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
raise exc
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\exceptions.py", line 87, in __call__
raise exc
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\exceptions.py", line 76, in __call__
await self.app(scope, receive, sender)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\routing.py", line 659, in __call__
await route.handle(scope, receive, send)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\responses.py", line 50, in __init__
self.init_headers(headers)
File "C:\Users\super\Desktop\Work\Charges2\venv\lib\site-packages\starlette\responses.py", line 77, in init_headers
and not (self.status_code < 200 or self.status_code in (204, 304))
TypeError: '<' not supported between instances of 'NoneType' and 'int'
Code (main.py):
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Folder Structure:
Pip Freeze:
anyio==3.5.0
asgiref==3.5.0
click==8.0.3
colorama==0.4.4
fastapi==0.73.0
h11==0.13.0
idna==3.3
pydantic==1.9.0
sniffio==1.2.0
starlette==0.18.0
typing_extensions==4.1.1
uvicorn==0.17.4
Using Python 3.10.2
CodePudding user response:
I get this error when trying to install your packages with pip install -r requirements.txt
:
ERROR: Cannot install -r requirements.txt (line 5) and starlette==0.18.0
because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested starlette==0.18.0
fastapi 0.73.0 depends on starlette==0.17.1
There must be some conflict between your dependencies. Try making a clean install of FastAPI.
If you suspect that there's a version issue, try installing your requirements from scratch.
If you want to prevent such conflicts in the future, a popular solution is to use a dependency management tool, such as pipenv
or poetry
.