准备编译环境,防止出现安装错误
yum groupinstall 'Development Tools'
[root@blog ~]# yum install zlib-devel bzip2-devel openssl-devel ncurese-devel -y

下载安装包
[root@blog ~]# cd /home/tools/ && wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz

解压
tar Jxvf Python-3.5.2.tar.xz

编译安装

[root@blog tools]# cd Python-3.5.2
[root@blog Python-3.5.2]# ./configure --prefix=/usr/local/python3.5.2 && make && make install

新建版本软连接,不要修改系统默认

[root@blog /]# ln -s /usr/local/python3.5.2/bin/python3.5 /usr/bin/python3
[root@blog /]# python3
Python 3.5.2 (default, Oct 18 2017, 16:24:24)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> quit()
[root@blog /]#
[root@blog /]# ln -s /usr/local/python3.5.2/bin/pip3.5 /usr/sbin/pip3

测试

  • [root@blog /]# python3
    Python 3.5.2 (default, Oct 18 2017, 16:24:24)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>>
    [root@blog /]# pip3 -V
    pip 8.1.1 from /usr/local/python3.5.2/lib/python3.5/site-packages (python 3.5)
    [root@blog /]#
  • 打赏作者

    Leave a Reply

    Your email address will not be published.