[Ubuntu 16.04~] pip upgrade 후 에러 해결 (ImportError: cannot import name 'main' )

2020. 2. 3. 21:15Debugging/Ubuntu

sudo apt install python-pip
pip install --upgrade pip

위와 같이 apt에서 설치한 pip(9.x 버전) 를 그대로 업데이트할 경우 다음과 같은 에러를 뿜는다

ImportError: cannot import name 'main' 

apt로 설치한 pip를 업그레이드 하면서 발생하는 경로 혹은 권한 문제인듯 함

버전에 맞게 다음 명령어로 기존 pip 제거 후 pip 공식 사이트에 있는 방법으로 설치하면 해결됨

python2:

sudo python3 -m pip uninstall pip

python3:

sudo python3 -m pip uninstall pip

이때 각 pip에 설치한 python package는 삭제되지 않음

그 다음 pip 재설치

python2:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python2 get-pip.py

python3:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py