安装python3.7版本:
- 下载源代码:
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
- 解压缩:
sudo tar -zxvf Python-3.7.1.tgz
- 安装依赖
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev
sudo apt install libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev
sudo apt install liblzma-dev libffi-dev libc6-dev
- 编译
cd Python-3.7.1/
sudo ./configure --prefix=/opt/python3.7
sudo make install
- 创建连接(设置默认版本)
sudo ln -s /opt/python3.7/bin/python3.7 /usr/bin/python3
如果显示python3已存在,则删除原版本:
rm -rf /usr/bin/python3
- 检查python版本
python3 -V
- 安装pip
#下载源代码 ,如果连接失效就自行到官网下载。
wget https://files.pythonhosted.org/packages/b8/d3/155ebd29b6e34ac283614d3a1e7f476ffb93f535aa0d8b3647fa014815aa/setuptools-54.1.2.tar.gz
wget https://files.pythonhosted.org/packages/b7/2d/ad02de84a4c9fd3b1958dc9fb72764de1aa2605a9d7e943837be6ad82337/pip-21.0.1.tar.gz
#解压
sudo tar -zxvf setuptools-54.1.2.tar.gz
sudo tar -zxvf pip-21.0.1.tar.gz
#安装setuptools
cd setuptools-54.1.2
sudo python3 setup.py build
sudo python3 setup.py install
#安装pip
cd ..
cd pip-21.0.1
sudo python3 setup.py build
sudo python3 setup.py install
#连接(设置默认pip3)
sudo ln -s /opt/python3.7/bin/pip3.7 /usr/bin/pip3
安装完成!!