ImportError: cannot import name 'sysconfig' from 'distutils'

ImportError: cannot import name 'sysconfig' from 'distutils'

Are you seeing an error or stacktrace like

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 14, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in <module>
    from pip.locations import (
  File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in <module>
    from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)

To fix the above error, install python3-distutils

$ sudo apt install python3-distutils

The distutils package provides support for building and installing additional modules into a Python installation.