본문 바로가기
프로그램 개발해서 돈벌기/일반

macOS에서 pip3 사용 시 externally-managed-environment를 만났을때 대응 방법

by ubmuhan 2024. 8. 6.
반응형

 

macOS 터미널에서 pip3 install xxxx을 시도 했는데 externally-managed-environment를 만난다면....

 

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a Python library that isn't in Homebrew,
    use a virtual environment:
    
    python3 -m venv path/to/venv
    source path/to/venv/bin/activate
    python3 -m pip install xyz
    
    If you wish to install a Python application that isn't in Homebrew,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. You can install pipx with
    
    brew install pipx
    
    You may restore the old behavior of pip by passing
    the '--break-system-packages' flag to pip, or by adding
    'break-system-packages = true' to your pip.conf file. The latter
    will permanently disable this error.
    
    If you disable this error, we STRONGLY recommend that you additionally
    pass the '--user' flag to pip, or set 'user = true' in your pip.conf
    file. Failure to do this can result in a broken Homebrew installation.
    
    Read more about this behavior here: <https://peps.python.org/pep-0668/>

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

[notice] A new release of pip is available: 24.0 -> 24.2
[notice] To update, run: python3.12 -m pip install --upgrade pip

 

위는 에러 전문입니다.

 

내용을 대충보면 pip 버전을 24.0에서 24.2로 올리라는 내용으로 보입니다.

 

brew install pipx

brew install xyz

python3.12 -m pip install --upgrade pip

python3 -m pip install --upgrade pip

pip3 install --upgrade pip

pip3 install --upgrade pip==24.2

 

그래서 구글링 해보고 위 설명에서 시킨데로 해보고 위 명령어를 다 시도해 보아도 같은 위 처럼 같은 에러 메시지만 출력이 되었습니다.

 

해결 방법을 역시 간단했습니다.

 


python3 -m pip config set global.break-system-packages true

 


 

위 에러 코드 설명을 잘 읽어 보면 해당 내용이 나옵니다.

 

"python3 -m pip config set global.break-system-packages true"

 

위를 실행하면

 

Writing to /Users/사용자 아이디/.config/pip/pip.conf

 

위와 같이 결과 메시지가 나옵니다.

 

이후

 

pip3 install --upgrade pip==24.2

 

위 명령어를 실행하면 pip 24.2 버전이 정상적으로 설치 되는 것을 확인 할 수 있습니다.

 

 

 

pip3 -V

 

pip3 -V 명령어로 24.2 버전이 정상적으로 설치된 것을 확인 할 수 있습니다.

반응형

댓글