成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

瀏覽:4日期:2022-07-02 11:05:07

最近在使用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ù)

Python 2.6.6升級(jí)到Python2.7.15的詳細(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è)試,否則為原版本的命令

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

4. 配置相關(guān)路徑下的python命令

# 查看python命令

whereis python

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

# 拷貝命令,修改配置軟鏈接,注意不能將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é)束

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

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

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

# 修改yum啟動(dòng)命令

vim /usr/bin/yum#將頭部#!/usr/bin/python 修改為 #!/usr/bin/python2.6

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

# 修改后測(cè)試,如下表明已修改好,yum可以正常工作了

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

至此,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,如下所示:

Python 2.6.6升級(jí)到Python2.7.15的詳細(xì)步驟

到此這篇關(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)!

標(biāo)簽: Python 編程
相關(guān)文章: