I would like to install pip within any of my virtual environments created with venv, but the get-pip.py script requires the distutils package, which is not installed in the server I am using, and I don't have root access. Is there any way to do it?

The server has Ubuntu 18.04, and the installed python version is 3.6.9.

Note that I am able to create virtual environments without pip installed using python3 -m venv name.

Also, note that this question is different to this one, because that only works when distutils package is installed in the system.

  • 1
    @GAD3R nope, as that only works if distutils package is installed in the system.
    – cserpell
    Commented Jan 30, 2021 at 23:02

1 Answer 1


As far as I can tell distutils is part of Python standard library, at least for Python 3. If you don't have it installed you must then have a botched Python installation (perhaps intentionally so by the hosting provider).

Regardless, the source for distutils can be found here. You only need to get a copy of it on the affected system (either via git clone or by downloading and extracting a tarball) and then set PYTHONPATH accordingly for get-pip.py to work:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .