distutilsパッケージがインストールされていないUbuntu> 18.04でrootアクセスなしでpipをインストールする方法

distutilsパッケージがインストールされていないUbuntu> 18.04でrootアクセスなしでpipをインストールする方法

pipを使用して作成した仮想環境にpipをインストールしたいが、スクリプトには使用しているvenvサーバーにインストールされていないパッケージがget-pip.py必要distutilsであり、rootアクセス権はありません。これを行う方法はありますか?

サーバーには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

おすすめ記事