docker-ubuntu-安装python3.8,pip3
目录
docker-ubuntu 安装python3.8,pip3
制作docker是,需要下载python3.8。
- 更换国内源
vim /etc/apt/sources.list
注释之前的,然后添加:
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# 源码
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# Canonical 合作伙伴和附加
deb http://archive.canonical.com/ubuntu/ xenial partner
更新:
apt-get update
- 安装依赖包
apt-get install software-properties-common
- 添加 deadsnakes PPA 源
add-apt-repository ppa:deadsnakes/ppa
4.下载python3.8
apt-get update
apt-get install python3.8
5.建立软链接
先删除旧的python连接。
删除后建立新的连接关系,例如linux下python3默认在/usr/bin/下
sudo rm -rf /usr/bin/python
ln -s /usr/bin/python3.8 /usr/bin/python
6.输入pip会找不到pip模块,这时候需要重新下载pip
进入python3.8的lib中:
cd /usr/lib/python3.8
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
python get-pip.py
然后,安装成功!!