728x90
반응형
1. ERROR 발생
pip를 이용해 패키지를 설치할 때, 아래와 같이 에러가 발생할 수 있습니다.
root@1dc05c27361c:/data/PyTorch# pip install torch torchvision
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
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.
2. 해결 방법
pip를 이용해 패키지를 설치할 경우, 시스템에 영향을 줄 수 있다고 하면서 에러가 발생한 상황입니다.
하지만 사용자가 패키지를 설치해도 문제가 없다고 판단한다면, pip에 권한을 부여해서 패키지를 설치할 수 있습니다.
pip에 설치 권한을 주는 것은 아래 커맨드를 통해 가능합니다.
python -m pip config set global.break-system-packages true
위 커맨드를 실행하면 아래와 같이 /root/.config.pip/pip.conf 파일을 수정했다고 출력됩니다.
cat을 통해 해당 파일을 확인해 보면, break-system-packages 옵션이 ture로 설정된 것을 확인할 수 있습니다.
위와 같이 설정한 이후에 다시 pip를 통해 패키지를 설치하면, 패키지가 정상적으로 잘 설치되는 것을 확인할 수 있습니다.
위 방법은 아래 사이트를 통해 해결책을 찾았습니다.
https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-every-time-i-use-pip-3
728x90
반응형
'FIX ERRORS' 카테고리의 다른 글
ModuleNotFoundError: No module named 'numba.decorators' 해결 방법 (0) | 2025.01.21 |
---|---|
libxml2.so.2: cannot open shared object file: No such file or directory 해결 방법 (11) | 2025.01.07 |
nvcc command not found 해결 방법, CUDA path 설정 방법 (15) | 2025.01.05 |
[ERROR] Missing gcc, Failed to verify gcc version 해결 방법, gcc 설치 방법 (9) | 2025.01.04 |
wget command not found 해결 방법, wget 설치 방법 (27) | 2025.01.03 |