默认安装的Python是python3.11,有些库需要用到旧版本的python。在此介绍一下python3.8的自定义安装。
一、安装依赖
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget -y
二、下载安装包
curl -O https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
三、解压和编译
tar -zxvf Python-3.8.0.tgz
cd Python-3.8.0
./configure --prefix=/usr/local/python3
make && make install
四、设置软连接
ln -sf /usr/local/python3/bin/python3.8 /usr/bin/python3
ln -sf /usr/local/python3/bin/pip3.8 /usr/bin/pip3