工作需要使用Python3.8以上版本。因此需要卸載系統(tǒng)之前其他版本的 Python。以下就是我卸載其他版本,安裝 Python3.8 版本步驟。
- 一、卸載Python3.6
// 查看版本
[root@localhost ~]#python -v
image.png
// 查找 Python 文件所在路徑
[root@localhost ~]# whereis python
// 卸載刪除 Python
[root@localhost ~]# rpm -qa|grep python3*|xargs rpm -ev --allmatches --nodeps
image.png
// 檢測是否卸載刪除干凈
[root@localhost ~]# python
image.png
- 下載 Python3.8
到官網(wǎng)下載所需要版本 python 安裝包
https://www.python.org/downloads/release/python-387/
image.png
找到Python3.8.7安裝包并下載,然后上傳到的 centos7 服務器上,準備進行安裝。
https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tgz
image.png - 安裝Python3.8
// 解壓縮
[root@localhost ~]# tar -xvf Python-3.8.7.tgz
image.png
// 執(zhí)行安裝
// 運行腳本configure
[root@localhost ~]# cd Python-3.8.7
[root@localhost Python-3.8.7]# ./configure --prefix=/usr/local/python3
// make編譯&make install安裝
[root@localhost Python-3.8.7]# make && make altinstall
// 運行make clean
// 刪除一些臨時文件
[root@localhost Python-3.8.7]# make clean
// 創(chuàng)建軟鏈接
// ln -s -f 強制創(chuàng)建軟連接
[root@localhost local] ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
[root@localhost local] ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
image.png
// 檢測安裝是否成功
[root@localhost ~]# python3 -V
image.png