Linux
error: uninstall-distutils-installed-package
KillinTime
2025. 1. 8. 22:51
Ubuntu에서 pip를 이용하여 Flask를 설치할 때, 아래와 같은 오류가 발생했다.
distutils는 초기 Python 패키지를 빌드하고 설치하는 도구이며,
Python이 최근 버전이면 distutils는 더 이상 사용되지 않고, setuptools와 pip를 사용한다.
Installing collected packages: blinker
Attempting uninstall: blinker
Found existing installation: blinker 1.4
error: uninstall-distutils-installed-package
× Cannot uninstall blinker 1.4
╰─> It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
pip로 관리되지 않는 패키지였고, pip list에 없었다.
아래 명령어를 이용했을 때는 있었다.
apt list --installed | grep blinker
이 경우는 apt에 있었기 때문에 remove 명령어로 지워주었다.
sudo apt remove python3-blinker
그리고 pip로 Flask를 재설치하여 해결하였다.
이 방법으로 되지 않는다면 직접 찾아서 제거하여야 한다.
# 오류가 발생한 패키지 이름을 입력
# ex) python3 -c "import {package}; print({package}.__file__)"
python3 -c "import blinker; print(blinker.__file__)"
# 예시 출력 결과 /usr/lib/python3.8/site-packages/blinker~이라면,
# 관련된 패키지를 삭제한다.
sudo rm -rf /usr/lib/python3.8/site-packages/blinker*