distutils 패키지가 설치되지 않은 Ubuntu > 18.04에서 루트 액세스 없이 pip를 설치하는 방법

distutils 패키지가 설치되지 않은 Ubuntu > 18.04에서 루트 액세스 없이 pip를 설치하는 방법

pip 를 사용하여 만든 가상 환경에 pip를 설치하고 싶지만 venv스크립트에는 사용 중인 서버에 설치되지 않은 패키지가 get-pip.py필요 distutils하고 루트 액세스 권한이 없습니다. 이를 수행할 수 있는 방법이 있습니까?

서버에는 Ubuntu 18.04가 있고 설치된 Python 버전은 3.6.9입니다.

pip.NET을 사용 하지 않고도 가상 환경을 만들 수 있습니다 python3 -m venv name.

또한 이 질문은 다음과 다릅니다.이것distutils, 패키지가 시스템에 설치된 경우 에만 작동하기 때문입니다 .

답변1

내가 아는 한 distutils는Python 표준 라이브러리의 일부, 적어도 Python 3의 경우. Python을 설치하지 않았다면 Python 설치에 결함이 있는 것입니다(호스팅 공급자가 의도적으로 설치한 것일 수 있음).

어쨌든 distutils의 소스는 다음과 같습니다.여기에서 발견. 영향을 받는 시스템에서 사본을 얻고( git clone타르볼을 다운로드하고 추출하여) PYTHONPATHget-pip.py가 작동하도록 적절하게 설정하면 됩니다.

9d3194663b77% git clone https://github.com/pypa/distutils
Cloning into 'distutils'...
remote: Enumerating objects: 1474, done.
remote: Counting objects: 100% (1474/1474), done.
remote: Compressing objects: 100% (659/659), done.
remote: Total 13343 (delta 890), reused 1362 (delta 811), pack-reused 11869
Receiving objects: 100% (13343/13343), 5.14 MiB | 22.78 MiB/s, done.
Resolving deltas: 100% (9592/9592), done.
9d3194663b77% cd distutils/distutils 
9d3194663b77% ls
README            bcppcompiler.py  config.py           dep_util.py  extension.py     log.py            py38compat.py  text_file.py      versionpredicate.py
__init__.py       ccompiler.py     core.py             dir_util.py  fancy_getopt.py  msvc9compiler.py  spawn.py       unixccompiler.py
_msvccompiler.py  cmd.py           cygwinccompiler.py  dist.py      file_util.py     msvccompiler.py   sysconfig.py   util.py
archive_util.py   command          debug.py            errors.py    filelist.py      py35compat.py     tests          version.py
9d3194663b77% cd ..

9d3194663b77% PYTHONPATH=. python3 ~/get-pip.py
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
  Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)
     |________________________________| 1.5 MB 7.1 MB/s 
Collecting setuptools
  Downloading setuptools-52.0.0-py3-none-any.whl (784 kB)
     |________________________________| 784 kB 39.9 MB/s 
Collecting wheel
  Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, setuptools, pip
  WARNING: The script wheel is installed in '/home/test/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pip, pip3 and pip3.7 are installed in '/home/test/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.0.1 setuptools-52.0.0 wheel-0.36.2

관련 정보