Ubuntu6.04升级python 3.5.2到3.7.3

在https://www.python.org/ftp/python/3.7.3/下载Python-3.7.3.tar.xz  解压

cd Python-3.7.3
sudo mkdir -p /usr/local/python3
./configure --prefix=/usr/local/python3  --enable-optimizations
make
sudo make install

删除软链接
先执行查看版本,如果有则证明软链接已存在,需要先删去以前的再重新建立

sudo rm -rf /usr/bin/python3
sudo rm -rf /usr/bin/pip3

建立新的软连接

#添加python3的软链接
sudo ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
#添加 pip3 的软链接
sudo ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3

检测版本

python3 -V
pip3-V

如有报错:

subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.

解决方法:
rm -rf /usr/bin/lsb_release

refer:

https://blog.csdn.net/lq497028254/article/details/100079641

https://blog.csdn.net/itdabaotu/article/details/83142918

你可能感兴趣的:(ubuntu,python)