Install and complie python3 env in ubuntu.

Install the complie env

1
2
apt-get update
apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev

Download source code

1
2
3
# 墙外墙内
wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz
wget https://cdn.npm.taobao.org/dist/python/3.8.3/Python-3.8.3.tgz

Unpacking

1
tar -xzf Python-3.8.3.tgz

Config the option of installation

1
2
3
4
5
6
7
cd Python-3.8.3
./configure --prefix=/usr/local/python3.8 # 设定安装目录
make && make install
ln -s /usr/local/python3.8/bin/python3.8 /usr/bin/python3.8
ln -s /usr/local/python3.8/bin/python3.8-config /usr/bin/python3.8-config
apt-get install python3-pip # 部分版本找不到pip
ln -s /usr/local/python3.8/bin/pip3 /usr/bin/pip3.8

More

1
2
3
4
5
6
7
8
9
10
11
$HOME/.pip/pip.conf中
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

others:
豆瓣 https://pypi.doubanio.com/simple/
网易 https://mirrors.163.com/pypi/simple/
阿里云 https://mirrors.aliyun.com/pypi/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/