安装pip报错Traceback (most recent call last): File
原创
©著作权归作者所有:来自51CTO博客作者codejam的原创作品,请联系作者获取转载授权,否则将追究法律责任
首选说明,我全部注释了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
,报错。 - 报错内容如下
root@zs-pc:/home/zs# python3 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 22318, in <module>
main()
File "get-pip.py", line 198, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip._internal.main
File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/main.py", line 13, in <module>
File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/cli/autocompletion.py", line 11, in <module>
File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/cli/main_parser.py", line 7, in <module>
File "/tmp/tmp0na1bhuz/pip.zip/pip/_internal/cli/cmdoptions.py", line 19, in <module>
ModuleNotFoundError: No module named 'distutils.util'
如下图:
解决办法:
在这个页面找到了办法。
Issue with “python3 get-pip.py --user” with python 3.6.7 #43
找到办法的楼层如图:
于是,
- 先执行这一条命令,
sudo apt-get install python3-distutils
- 然后得到这样一个东西
python3-distutils_3.6.9-1~18.04_all.deb
- 再执行之前的
python3 get-pip.py
命令即可。
执行后如图: - 然后pip可用,就不上图了。