Ubuntu18.04 (Python3.9) 报错 ImportError: Cannot import name 'sysconfig' from 'distutils'

1. 使用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. 解决方案:

2.1 安装pip 

 1 sudo apt-get install python3-pip 

 

2.2 安装distutils

 1 sudo apt-get install python3.9-distutils 

 

PS:Python3.5以后的版本,在安装distutils时,要以具体版本来进行安装 

sudo apt-get install python3.X-distutils

 

3. 安装成功

全部安装成功后, pip -V 可以正常运行使用pip。

 

posted @ 2021-12-27 16:38  缓下脚步  阅读(3208)  评论(0编辑  收藏  举报