又是一个美好而又期待的周末即将到来,再记录下方才遇到的问题:
AttributeError: ‘FastAPI’ object has no attribute ‘_debug’
不扯犊子了,直接摆出来解决方案:
版本冲突导致
fastapi==0.89.1
pip install starlette==0.22.0
切换成这个版本后就成功了;
错误的一些版本查询日志:
wsw@wsw88:/home$ pip list | grep fastap
fastapi 0.92.0
WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available ce this warning and allow it anyway with '--trusted-host pypi.douban.com'.
wsw@wsw88:/home$ pip list | grep starlette
starlette 0.25.0
WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.douban.com'.
wsw@wsw88:/home$ pip install starlette==0.22.0
Looking in indexes: http://pypi.douban.com/simple
Collecting starlette==0.22.0
Downloading http://pypi.doubanio.com/packages/1d/4e/30eda84159d5b3ad7fe663c40c49b16dd17436abe838f10a56c34bee44e8/starlette-0.22.0-py3-none-any.whl (64 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.3/64.3 kB 2.6 MB/s eta 0:00:00
Requirement already satisfied: typing-extensions>=3.10.0 in ./wsw/lib/python3.8/site-packages (from starlette==0.22.0) (4.5.0)
Requirement already satisfied: anyio<5,>=3.4.0 in ./wsw/lib/python3.8/site-packages (from starlette==0.22.0) (3.6.2)
Requirement already satisfied: idna>=2.8 in ./wsw/lib/python3.8/site-packages (from anyio<5,>=3.4.0->starlette==0.22.0) (3.4)
Requirement already satisfied: sniffio>=1.1 in ./wsw/lib/python3.8/site-packages (from anyio<5,>=3.4.0->starlette==0.22.0) (1.3.0)
Installing collected packages: starlette
Attempting uninstall: starlette
Found existing installation: starlette 0.25.0
Uninstalling starlette-0.25.0:
Successfully uninstalled starlette-0.25.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
fastapi 0.92.0 requires starlette<0.26.0,>=0.25.0, but you have starlette 0.22.0 which is incompatible.
Successfully installed starlette-0.22.0
wsw@wsw88:/home$ pip install fastapi==0.89.1
Looking in indexes: http://pypi.douban.com/simple
Collecting fastapi==0.89.1
Downloading http://pypi.doubanio.com/packages/8f/89/adf4525d1870021b65ec562e83e9f46d96494ad95f238d0264ef1ab6b604/fastapi-0.89.1-py3-none-any.whl (55 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 55.8/55.8 kB 3.3 MB/s eta 0:00:00
Requirement already satisfied: pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2 in ./wsw/lib/python3.8/site-packages (from fastapi==0.89.1) (1.10.5)
Requirement already satisfied: starlette==0.22.0 in ./wsw/lib/python3.8/site-packages (from fastapi==0.89.1) (0.22.0)
Requirement already satisfied: typing-extensions>=3.10.0 in ./wsw/lib/python3.8/site-packages (from starlette==0.22.0->fastapi==0.89.1) (4.5.0)
Requirement already satisfied: anyio<5,>=3.4.0 in ./wsw/lib/python3.8/site-packages (from starlette==0.22.0->fastapi==0.89.1) (3.6.2)
Requirement already satisfied: sniffio>=1.1 in ./wsw/lib/python3.8/site-packages (from anyio<5,>=3.4.0->starlette==0.22.0->fastapi==0.89.1) (1.3.0)
Requirement already satisfied: idna>=2.8 in ./wsw/lib/python3.8/site-packages (from anyio<5,>=3.4.0->starlette==0.22.0->fastapi==0.89.1) (3.4)
Installing collected packages: fastapi
Attempting uninstall: fastapi
Found existing installation: fastapi 0.92.0
Uninstalling fastapi-0.92.0:
Successfully uninstalled fastapi-0.92.0
Successfully installed fastapi-0.89.1
wsw@wsw88:/home$ pip install starlette==0.22.0
Looking in indexes: http://pypi.douban.com/simple
Requirement already satisfied: starlette==0.22.0 in ./wsw/lib/python3.8/site-packages (0.22.0)
Requirement already satisfied: typing-extensions>=3.10.0 in ./wsw/lib/python3.8/site-packages (from starlette==0.22.0) (4.5.0)
Requirement already satisfied: anyio<5,>=3.4.0 in ./wsw/lib/python3.8/site-packages (from starlette==0.22.0) (3.6.2)
Requirement already satisfied: sniffio>=1.1 in ./wsw/lib/python3.8/site-packages (from anyio<5,>=3.4.0->starlette==0.22.0) (1.3.0)
Requirement already satisfied: idna>=2.8 in ./wsw/lib/python3.8/site-packages (from anyio<5,>=3.4.0->starlette==0.22.0) (3.4)