[root@VM_109_202_centos /]# cd /usr/local/src/
[root@VM_109_202_centos src]# wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz
2、解压缩
我们用tar命令把下载的包解压缩,以下省略解压所产生的信息,如下:
[root@VM_109_202_centos src]# ls -l
total 14484
-rw-r--r-- 1 root root 14808460 Sep 132015 Python-3.5.0.tar.xz
[root@VM_109_202_centos src]# tar xvJf Python-3.5.0.tar.xz
...
...
[root@VM_109_202_centos src]# ls -l
total 14488
drwxrwxr-x 16 oldwang oldwang 4096 Sep 132015 Python-3.5.0
-rw-r--r-- 1 root root 14808460 Sep 132015 Python-3.5.0.tar.xz
3、编译和安装
进入Python-3.5.0文件夹,注: –prefix用于指定要安装的目录:
[root@VM_109_202_centos src]# cd Python-3.5.0/
[root@VM_109_202_centos Python-3.5.0]# ./configure --prefix=/usr/local/python-3.5
[root@VM_109_202_centos Python-3.5.0]# make
[root@VM_109_202_centos Python-3.5.0]# make install
4、检查python的版本
进入/usr/local/python-3.5/, 输入python,我的提示信息是这样的:
[root@VM_109_202_centos python-3.5]# python
Python 2.7.5 (default, Sep 152016, 22:37:39)
[GCC 4.8.520150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license"for more information.
>>>