티스토리 뷰
Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.
Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.
아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

Error after upgrading pip: cannot import name 'main'
pip 업그레이드 후 오류: cannot import name 'main'
문제 내용
Whenever I am trying to install any package using pip, I am getting this import error:
pip을 사용하여 패키지를 설치하려고 할 때마다 다음 가져오기 오류가 발생합니다.
guru@guru-notebook:~$ pip3 install numpy
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
guru@guru-notebook:~$ cat `which pip3`
#!/usr/bin/python3
# GENERATED BY DEBIAN
import sys
# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
from pip import main
if __name__ == '__main__':
sys.exit(main())
It was working fine earlier, I am not sure why it is throwing this error. I have searched about this error, but can't find anything to fix it.
아까는 정상적으로 작동했는데, 왜 이런 오류가 발생하는지 모르겠네요. 이 오류에 대해 검색했지만 수정할 수 있는 것을 찾을 수 없습니다.
Please let me know if you need any further detail, I will update my question.
추가로 필요한 사항이 있으면 말씀해주시면 제 질문을 업데이트하겠습니다.
높은 점수를 받은 Solution
You must have inadvertently upgraded your system pip (probably through something like sudo pip install pip --upgrade
)
실수로 시스템 파이프를 업그레이드한 것 같습니다(아마 sudo pip install pip --upgrade 같은 것을 통해).
pip 10.x adjusts where its internals are situated. The pip3
command you're seeing is one provided by your package maintainer (presumably debian based here?) and is not a file managed by pip.
pip 10.x는 내부 위치를 조정합니다. 지금 보시는 pip3 명령어는 패키지 관리자가 제공하는 명령어(아마도 여기 기반의 debian?)이며 pip에 의해 관리되는 파일이 아닙니다.
You can read more about this on pip's issue tracker
이에 대한 자세한 내용은 pip의 이슈 트래커에서 확인할 수 있습니다.
You'll probably want to not upgrade your system pip and instead use a virtualenv.
시스템 파이프를 업그레이드하지 않고 가상 env를 사용하는 것이 좋습니다.
To recover the pip3
binary you'll need to sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
.
pip3 바이너리를 복구하려면 python3-m pip 제거 pip & sudo apt install python3-pip --reinstall이 필요합니다.
If you want to continue in "unsupported territory" (upgrading a system package outside of the system package manager), you can probably get away with python3 -m pip ...
instead of pip3
.
지원되지 않는 영역(시스템 패키지 관리자 외부의 시스템 패키지 업그레이드)에서 계속하고 싶다면 python 3-m pip으로 빠져나갈 수 있습니다. pip3 대신에.
가장 최근 달린 Solution
You can resolve this issue by reinstalling pip.
pip를 다시 설치하여 이 문제를 해결할 수 있습니다.
Use one of the following command line commands to reinstall pip:
다음 명령줄 명령 중 하나를 사용하여 pip을 다시 설치합니다.
Python2:
파이썬2:
python -m pip uninstall pip && sudo apt install python-pip --reinstall
Python3:
파이썬3:
python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
출처 : https://stackoverflow.com/questions/49836676/error-after-upgrading-pip-cannot-import-name-main
'개발 > 파이썬' 카테고리의 다른 글
Mac OS에서 PIP를 사용하여 PIL을 설치하는 방법은 무엇입니까? (0) | 2022.11.26 |
---|---|
pandas에서 열 집합 선택/제외 (0) | 2022.11.26 |
"ValueError: attempted relative import beyond top-level package" 문제 수정 (0) | 2022.11.26 |
가져오기 오류: No module name urllib2 (0) | 2022.11.26 |
파이썬3에서 StringIO 사용 방법 (0) | 2022.11.26 |