当前位置:Gxl网 > 互联网 > 安装pip报错Traceback (most recent call last): File "get-pip.py", line 22318, in <module> main()

安装pip报错Traceback (most recent call last): File "get-pip.py", line 22318, in <module> main()

时间:2021-07-01 10:21:17 帮助过:5人阅读

原文链接:

首选说明,我全部注释了Ubuntu自带的源,全改成了aliyun的源头,并且出于F墙状态

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

某些源可能找不到这个 python3-distutils 包,反正至少上面这个可以找到,当前日期2019年12月27日。

问题背景:
WSL Ubuntu,自带python 3.6.7,想要安装pip环境,以便进一步安装其他环境。
但是现在试图安装pip的过程中报错:

先下载get-pip.py 文件。
执行命令 python3 get-pip.py,报错。
报错内容如下

 1 root@zs-pc:/home/zs# python3 get-pip.py 
 2 Traceback (most recent call last):
 3   File "get-pip.py", line 22318, in 
 4     main()
 5   File "get-pip.py", line 198, in main
 6     bootstrap(tmpdir=tmpdir)
 7   File "get-pip.py", line 82, in bootstrap
 8     import pip._internal.main
 9   File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/main.py", line 13, in 
10   File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/cli/autocompletion.py", line 11, in 
11   File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/cli/main_parser.py", line 7, in 
12   File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/cli/cmdoptions.py", line 19, in 
13 ModuleNotFoundError: No module named ‘distutils.util‘

如下图:技术图片

技术图片

解决办法:

在这个页面找到了办法。

找到办法的楼层如图:

 技术图片

 

 

于是,

    1. 先执行这一条命令,sudo apt-get install python3-distutils
    2. 然后得到这样一个东西 python3-distutils_3.6.9-1~18.04_all.deb
    3. 再执行之前的python3 get-pip.py命令即可。
      执行后如图
    4. 技术图片

       

      然后pip可用,就不上图了。