Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟
最近在使用Python處理MySQL數(shù)據(jù)庫(kù)相關(guān)問(wèn)題時(shí),需要用到Python2.7.5及以上版本,而centos6.5等版本操作系統(tǒng)默認(rèn)自帶的版本為2.6.6,因此需要對(duì)python進(jìn)行升級(jí)。
Python升級(jí)的步驟大致分為如下步驟:
安裝依賴包 下載安裝包并上傳至操作系統(tǒng),下載路徑 解壓、編譯、安裝 配置相關(guān)路徑下的python命令 修改yum啟動(dòng)路徑1. 安裝依賴包
# 編譯時(shí)需要使用gcc,故需先檢查并安裝gcc
yum install gcc -y
2. 下載安裝包并上傳至操作系統(tǒng)
# 本次采用wget直接在linux系統(tǒng)下載。下載路徑為python官網(wǎng)https://www.python.org/ftp/python,選擇對(duì)應(yīng)的版本,并下載
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
3. 解壓、編譯、安裝
# 解壓
tar -zxvf Python-2.7.15.tgz
# 編譯、安裝
cd Python-2.7.15./configure --prefix=/usr/local/python2.7
檢查是否有錯(cuò)誤,如無(wú)錯(cuò)誤則繼續(xù)
makemake install
# 查看安裝結(jié)果
cd /usr/local/python2.7/binll./python2 #運(yùn)行本路徑下的python2,或?qū)懭窂綔y(cè)試,否則為原版本的命令./python2.7 #運(yùn)行本路徑下的python2,或?qū)懭窂綔y(cè)試,否則為原版本的命令
4. 配置相關(guān)路徑下的python命令
# 查看python命令
whereis python
# 拷貝命令,修改配置軟鏈接,注意不能將python2.6版本的命令刪除,因?yàn)閥um不支持python2.7,后續(xù)修改yum命令時(shí)需要用到python2.6
cd /usr/binll *python*unlink pythonunlink python2ll *python*cp /usr/local/python2.7/bin/python2.7 /usr/bin/python2.7 #注意路徑ln -s /usr/bin/python2.7 pythonln -s python python2ll *python* python #可以看到提示的Python2.7.15,證明安裝成功,但是還沒(méi)有徹底結(jié)束
5.修改yum啟動(dòng)路徑
yum不兼容 Python 2.7,當(dāng)把Python2.6.6升級(jí)成了Python2.7以后, yum將不能正常工作,因此需要指定 yum 的Python版本
# 升級(jí)后運(yùn)行yum命令報(bào)錯(cuò)信息
There was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was:No module named yumPlease install a package which provides this module, orverify that the module is installed correctly.It’s possible that the above module doesn’t match thecurrent version of Python, which is:2.7.15 (default, Jun 25 2018, 09:22:50) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]If you cannot solve this problem yourself, please go to the yum faq at:http://yum.baseurl.org/wiki/Faq
# 修改yum啟動(dòng)命令
vim /usr/bin/yum#將頭部#!/usr/bin/python 修改為 #!/usr/bin/python2.6
# 修改后測(cè)試,如下表明已修改好,yum可以正常工作了
至此,python2.6.6升級(jí)為python2.7.15工作就完成了,運(yùn)行python命令就相當(dāng)于運(yùn)行python2.7.15版本的Python,運(yùn)行python2.6即使用python2.6.6版的python,如下所示:
到此這篇關(guān)于Python 2.6.6升級(jí)到Python2.7.15的過(guò)程詳解的文章就介紹到這了,更多相關(guān)Python 2.6.6升級(jí)到Python2.7.15內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. IntelliJ IDEA導(dǎo)出項(xiàng)目的方法2. IntelliJ IDEA設(shè)置自動(dòng)提示功能快捷鍵的方法3. IntelliJ IDEA設(shè)置編碼格式的方法4. JS實(shí)現(xiàn)炫酷雪花飄落效果5. Ajax對(duì)xml信息的接收和處理操作實(shí)例分析6. 用XML和XSL來(lái)生成動(dòng)態(tài)頁(yè)面7. Ajax報(bào)錯(cuò)400的參考解決辦法8. 谷歌Chrome瀏覽器開(kāi)發(fā)者工具教程—JS調(diào)試篇9. Ajax實(shí)現(xiàn)頁(yè)面無(wú)刷新留言效果10. WML開(kāi)發(fā)教程之 WAP網(wǎng)站服務(wù)器配置方法
