linux服务器升级python(python2和python3共存)

先安装sqlite-devel,

1
yum -y install sqlite-devel 
1
2
3
4
5
6
mkdir /usr/local/python3
cd /usr/local/
wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tar.xz
tar -xvJf Python-3.10.4.tar.xz
cd Python-3.10.4
./configure prefix=/usr/local/python3

在Python-3.10.4目录下执行下面的命令(下载pip等插件的命令)
下载和编译安装

1
make && make install 

建立软连接

1
2
ln -fs /usr/local/python3/bin/python3 /usr/bin/python3
ln -fs /usr/local/python3/bin/pip3 /usr/bin/pip3

linux下更新pip

1
2
3
pip install --upgrade pip
pip3 install --upgrade pip
sudo pip3 install --upgrade pip