To solve ImportError: cannot import name ‘sysconfig’ from ‘distutils’ (/usr/lib/python3.8/distutils/__init__.py) follow any of the below methods.
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in from distutils import sysconfig ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/init.py
How to solve ImportError: cannot import name ‘sysconfig’ from ‘distutils’ (/usr/lib/python3.8/distutils/__init__.py) ?
I recently attempted to manually install Python 3.9 in Ubuntu from the 3.6 version using
apt install python3.9. Then pip3 failed. The problem is that distutils was not built for the 3.9 version. Run the code below :
apt install python3.9-distutils
Also try below solutions as well.
python3 get-pip.py --force-reinstall
or upgrade it.
python3.10 -m ensurepip --upgrade
Hope it solves.