CENTOS安装Python3.7.2

1、在CentOS中下载最新的Python版本,我这里下载的是3.7.2版本。

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

[root@VM_0_15_centos software]# wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
--2018-12-27 17:07:37--  https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
Resolving www.python.org (www.python.org)... 151.101.108.223, 2a04:4e42:2d::223
Connecting to www.python.org (www.python.org)|151.101.108.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22897802 (22M) [application/octet-stream]
Saving to: ‘Python-3.7.2.tgz’

100%[===================================================================================================>] 22,897,802   381KB/s   in 20s    

2018-12-27 17:07:59 (1.07 MB/s) - ‘Python-3.7.2.tgz’ saved [22897802/22897802]

2、解压安装包

tar -zxvf Python-3.7.2.tgz

[root@VM_0_15_centos software]# tar -zxvf Python-3.7.2.tgz

 

3、删除旧版本的python依赖

 ll /usr/bin |grep python

 rm -rf /usr/bin/python

[root@VM_0_15_centos software]# ll /usr/bin |grep python
-rwxr-xr-x. 1 root root       11232 Aug 10  2017 abrt-action-analyze-python
lrwxrwxrwx. 1 root root           7 Jan  9  2018 python -> python2
lrwxrwxrwx. 1 root root           9 Jan  9  2018 python2 -> python2.7
-rwxr-xr-x. 1 root root        7136 Aug  4  2017 python2.7
[root@VM_0_15_centos software]# rm -rf /usr/bin/python

4、 进入python目录并配置、编译

cd /usr/local/Python-3.7.2/^C
 ./configure

[root@VM_0_15_centos Python-3.7.2]# cd /usr/local/Python-3.7.2/^C
[root@VM_0_15_centos Python-3.7.2]# ./configure

编译:make

[root@VM_0_15_centos Python-3.7.2]# make

编译安装:make install

[root@VM_0_15_centos Python-3.7.2]# make install

5、删除旧的软链接,创建新的。

 rm -rf /usr/local/pthon3

 ln -s /usr/local/bin/python3.7 /usr/bin/python

python -v

[root@VM_0_15_centos Python-3.7.2]# rm -rf /usr/local/pthon3
[root@VM_0_15_centos bin]# rm -rf /usr/bin/python
[root@VM_0_15_centos bin]#  ln -s /usr/local/bin/python3.7 /usr/bin/python
[root@VM_0_15_centos bin]# python -V
Python 3.7.2

 

你可能感兴趣的:(Python)