Tag Archives: ImportError: Cannot import name ‘sysconfig’ from ‘distutils’

Ubuntu18.04 (Python3.9) Error: ImportError: Cannot import name ‘sysconfig’ from ‘distutils’

1. Error reporting when using PIP:

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

2. Solution:

2.1 installation pip

1 sudo apt-get install python3-pip

2.2 installing distutils

1 sudo apt-get install python3. 9-distutils

PS:Python3. For versions after 5, when installing distutils, you should install it with a specific version

sudo apt-get install python3.X-distutils

3. Installation succeeded

After all installations are successful, PIP – V can run normally and use pip.