一、确实当前python版本
[root@centos Python-3.6.1]# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
以上输出Python 2.7.5表示当前版本,因为yum使用的是Python2.7因此不能删除,所以只能重新安装一个替换版本。
输入以下命令查看目前系统使用的Python以及安装目录,接下来将要对该目录下的Python进行修改
[root@centos ~]# which python
/usr/bin/python
[root@centos ~]# ll /usr/bin/python*
lrwxrwxrwx. 1 root root 7 May 30 05:52 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root 9 May 30 05:52 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 Nov 6 2016 /usr/bin/python2.7
二、下载安装
官网下载需要的Python版本,通过 WinSCP(安装使用教程)将下载的Python文件上传到服务器目录
解压Python安装包
tar -zxvf Python-3.6.1.tgz
解压后进到Python根目录查看README文件,里面介绍了安装方法,这里跳过test步骤
Paste_Image.png
根据文档介绍执行第一步./configure –prefix=/usr/local/python3,后面添加参数为Python安装目录,默认安装目录为/usr/local/,如果出现以下错误提示则表示系统没有安装gcc
configure: error: no acceptable C compiler found in $PATH
安装gc