如题,博主废了不少劲,折腾了一个上午终于搞定了
本次采用环境是ubuntu1804系统的docker容器,并且容器内部已更换阿里源
编辑阿里源:
vi /etc/apt/sources.list
然后粘贴下面内容,再保存
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
然后依次执行下方命令
apt-get update
apt install software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt install python3.8 python3.8-dev python3.8-distutils python3.8-venv
将 python3.6 和 3.8 添加到 update-alternatives
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
将 python3 指向 python3.8
> sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3.8 2 auto mode
1 /usr/bin/python3.6 1 manual mode
2 /usr/bin/python3.8 2 manual mode
Press <enter> to keep the current choice[*], or type selection number:
可以看到,已经默认指向了 python3.8,按回车即可。
测试一下,可以看到指向已更新。
> python3
Python 3.8.0 (default, Dec 9 2021, 17:53:27)
接下来安装pip适用于python3.8的版本
python3 -m ensurepip
python3 -m pip install --upgrade pip setuptools wheel
sudo apt install --fix-missing python3-pip
再输入pip3不报错就是对了
#输入
pip3 -V
#显示
pip 22.0.4 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)