更新python版本

2021-07-09 01:58:12 字數 2615 閱讀 6575

wget 

解壓檔案

[test@localhost ~]$ tar zxvf python-2.7.11.tar.tgz

[test@localhost ~]$ cd python-2.7.11

[test@localhost python-2.7.11]$ su -

口令:[root@localhost python-2.7.11]# mkdir /usr/local/python2.7.11

[root@localhost python-2.7.11]# ls

config.guess configure 

demo  grammar install-sh  license makefile.pre.in  modules parser pcbuild 

python riscos 

tools

config.sub 

configure.ac doc 

include lib 

mac 

misc 

objects pc 

pyconfig.h.in  readme setup.py 

[root@localhost python-2.7.11]# ./configure  --prefix=/usr/local/python2.7.11

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu

checking for --enable-universalsdk... no

checking for --with-universal-archs... 32-bit

checking machdep... linux2

checking extraplatdir...

checking for --without-gcc... no

checking for gcc... no

checking for cc... no

checking for cl.exe... no

configure: error: in `/home/niuxl/python-2.7.11':

configure: error: no acceptable c compiler found in $path

缺少c編輯器

[root@localhost python-2.7.11]# yum install gcc

..略gcc安裝完成

繼續編譯python

[root@localhost python-2.7.11]# ./configure  --prefix=/usr/local/python2.7.4

..(略)

ok編譯成功

[root@localhost python-2.7.11]# make&& make install

安裝成功

[root@localhost python-2.7.11]# python -v

python 2.6.6

目前版本依然是2.6.6,現在開始公升級python,

檢視python命令所在目錄

[root@localhost python-2.7.11]# whereis python

python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.6/usr/include/python2.6 /usr/share/man/man1/python.1.gz

將/usr/bin/python 的軟連線修改為python2.6.6

[root@localhost python-2.7.11]# mv /usr/bin/python /usr/bin/python2.6.6

[root@localhost python-2.7.11]# python

-bash: /usr/bin/python: 沒有那個檔案或目錄

python命令找不到,這時只需要將版本python2.7.11命令加入環境變數即可!

方式1:

修改/etc/profile加入如下兩行:

path=$path:/usr/local/python2.7.11/bin

export path

然後[root@localhost python-2.7.11]# source /etc/profile

[root@localhost python-2.7.11]# python -v

python 2.7.4

當然也可以建立2.7.11版本的python的軟連線:/usr/bin/python

[root@localhost ~]# ln -sv /usr/local/python2.7.11/bin/python  /usr/bin/python

亦可ok,python公升級完成

到現在為止,還有最後一件事需要做,那就是yum與python的相容問題:

[root@localhost pipe]# vi /usr/bin/yum

#!/usr/bin/python

第一行修改為

#!/usr/bin/python2.6.6(即原始的python變更後的名字)

python版本更新 python 版本公升級

python 版本公升級 公升級python 檢視python的版本 python v python 2.6.6 wget 解壓tar xvf python 2.7.12.tgz 安裝cd python 2.7.12 configure prefix usr local python2.7 make...

Ubuntu下更新python版本

wgettar xvjf python 2.7 3.tar bz2進入解壓縮後的資料夾 cd python 2.7.3在編譯前先在 usr local建乙個資料夾python27 作為python的安裝路徑,以免覆蓋老的版本 mkdir usr local python27在解壓縮後的目錄下編譯安裝...

CentOS下更新Python版本

前幾天centos放出5.x系列終極版本centos5.9 final 像我這樣有強迫症的人是不會放過這個更新的機會的。更新python千萬不要把老版本的刪除!新老版本是可以共存的,很多基本的命令 軟體包都要依賴預裝的老版本python的,比如yum。下面講一下更新的方法 第1步 更新一下你的gcc...