方法一,線上安裝
# 下載Python源(Download Python source)
$wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz
# 提取Python包(Extract Python package):
$tar xf Python-3.5.1.tar.xz
$xz -d Python-3.5.1.tar.xz
$cd Python-3.5.1
# 編譯的Python(Compile Python):
$./configure
# Make:
$make
# 安裝(Install):
$make install
# 檢查Python版本(Check Python version):
$which python3.5
/usr/local/bin/python3.5
方法二,另一種安裝方法
1、在官方網站下載python安裝包,這裡注意python.org/download路徑被屏蔽,需要使用http://www.python.org/頁面上的中文“下載”連結進行下載。
這裡下載了python最新的3.2.2版本:Python-3.2.2.tgz
下載後,檔案目錄在/home/python/下,這也是我python的安裝目錄
2、解壓:
[root@www python]# tar zxvf Python-3.2.2.tgz
3、開啟安裝目錄,執行:
[root@www python]# cd Python-3.2.2
[root@www Python-3.2.2]#./configure
[root@www Python-3.2.2]# make
[root@www Python-3.2.2]# makeinstall
值此,安裝完成。
4、但此時輸入”python”命令,仍然顯示是舊版本的,這就需要建立軟串連:
[root@www bin]# cd /usr/bin
[root@www bin]# ll |grep python
[root@www bin]# rm -rf python
[root@www bin]# ln -s /home/python/Python-3.2.2/python python
[root@www bin]# python
Python 3.2.2 (default, Oct 26 2011, 23:40:16)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or"license" for more information.
>>>