관리 메뉴

솜씨좋은장씨

[FastAPI] APIRouter TypeError: __init__() got an unexpected keyword argument 'tags' 해결방법 (Python) 본문

Programming/Python

[FastAPI] APIRouter TypeError: __init__() got an unexpected keyword argument 'tags' 해결방법 (Python)

솜씨좋은장씨 2021. 8. 9. 17:33
728x90
반응형

FastAPI로 API를 개발하면서

from fastapi import APIRouter
router = APIRouter(tags=["template crud"])

위처럼 FastAPI의 APIRouter를 활용하여 개발한 후에 호기롭게 실행하였는데...!

    router = APIRouter(tags=["template crud"])
TypeError: __init__() got an unexpected keyword argument 'tags'

위처럼 APIRouter는 tags라는 항목을 가지고 있지 않다는 오류가 발생하였습니다.

 

원인

원인은 내 컴퓨터 또는 서버에 설치되어있는 FastAPI의 버전이 낮아 발생하는 오류입니다.

해결방법

pip를 최신버전으로 업데이트 한 이후에

$ python3 -m pip install --upgrade pip

현재 설치되어있는 FastAPI를 삭제하고  최소 0.64.0 버전 이상으로 설치해줍니다.

$ pip uninstall fastapi
$ pip install fastapi>=0.64.0

 

그러고 나서 다시 실행해보면 문제없이 제대로 동작하는 것을 볼 수 있습니다.

 

읽어주셔서 감사합니다.

Comments