본문 바로가기
코딩 연습/코딩배우기

파이썬 pip 명령 에러 메시지 - ModuleNotFoundError: No module named 'pip'

by good4me 2021. 12. 12.

goodthings4me.tistory.com

 

pip 명령 에러 메시지 - No module named 'pip'

pip 명령 오류

가상환경에서 잘 사용하던 pip 명령이 업그레이드 이후 가상환경에서 python.exe -m pip install --upgrade pip가 아닌 pip install --upgrade pip 명령으로 업그레이드를 했는데, 이 명령에 어떤 문제가 있었던 건지 pandas 설치를 했는데 ModuleNotFoundError: No module named 'pip' 메시지가 계속 발생하였다.

 

pip 버전을 확인했으나 동일한 에러 메시지가 발생함

(venv) D:\Ex_noviceCoding>pip --version
Traceback (most recent call last):
  File "C:\Anaconda39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Anaconda39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Ex_noviceCoding\venv\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

(venv) D:\Ex_noviceCoding>

 

구글에서 원인을 찾아보니, 
pip install --upgrade pip 명령을 수행한 후 나타나는 현상이고, pip 업그레이드 명령 시 pip 패키지를 삭제하고 다시 설치하는 과정에서 제대로 되지 않아서 발생한다고....
아래처럼 python -m ensurepip 명령으로 해결했다.

 

(venv) D:\Ex_noviceCoding>python -m ensurepip
WARNING: Ignoring invalid distribution 
-ip (d:\ex_novicecoding\venv\lib\site-packages)
WARNING: Ignoring invalid distribution 
-ip (d:\ex_novicecoding\venv\lib\site-packages)
Looking in links: c:\Users\Public\Documents\ESTsoft\CreatorTemp\tmp0wvqida_   
Requirement already satisfied: setuptools in d:\ex_novicecoding\venv\lib\site-packages (57.4.0)     
Processing c:\users\public\documents\estsoft\creatortemp\tmp0wvqida_\pip-21.2.3-py3-none-any.whl
WARNING: Ignoring invalid distribution 
-ip (d:\ex_novicecoding\venv\lib\site-packages)
Installing collected packages: pip
WARNING: Ignoring invalid distribution 
-ip (d:\ex_novicecoding\venv\lib\site-packages)
Successfully installed pip-21.2.3

(venv) D:\Ex_noviceCoding>pip --version
pip 21.2.3 from D:\Ex_noviceCoding\venv\lib\site-packages\pip (python 3.9)

(venv) D:\Ex_noviceCoding>

 

good4me.co.kr

 

댓글