python3.6配置安装

1.查看当前python版本

[root@shuai Downloads]# python -V
Python 2.6.6

2.创建下载存放目录,然后进入存放目录

[root@shuai ~]# mkdir /root/Downloads
[root@shuai ~]# cd /root/Downloads/

3.获取新版的python

[root@shuai Downloads]# wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

4.解压文件

[root@shuai Downloads]# tar zxvf Python-3.6.4.tgz

5.进入解压后的文件目录

[root@shuai Downloads]# cd Python-3.6.4

6.配置编译安装目录

[root@shuai Python-3.6.4]# yum -y install openssl-devel
[root@shuai Python-3.6.4]# ./configure --prefix=/usr/local/python3 --with-ssl

7.编译安装

[root@shuai Python-3.6.4]# make && make install

解决 zipimport.ZipImportError: can't decompress data; zlib not available 的方法:

1.下载源码: http://www.zlib.net/
2.解压安装:

[root@shuai Python-3.6.4]#  cd /root/Downloads/
[root@shuai Downloads]# wget http://www.zlib.net/zlib-1.2.11.tar.xz
[root@shuai Downloads]# tar xvf zlib-1.2.11.tar.xz
[root@shuai Downloads]# cd zlib-1.2.11
[root@shuai zlib-1.2.11]# ./configure 
[root@shuai zlib-1.2.11]# make && make install

重新安装 python3:

[root@shuai Downloads]# cd Python-3.6.4
[root@shuai Python-3.6.4]# ./configure --prefix=/usr/local/python3 --with-ssl
[root@shuai Python-3.6.4]# make && make install

出现这个代表编译安装成功

8.添加软链接

[root@shuai Python-3.6.4]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@shuai Python-3.6.4]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

9.再次查看python版本号:发现升级python3.6成功了!

[root@shuai Python-3.6.4]# python3 -V
Python 3.6.4

[root@localhost ~]# pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)
Last modification:July 24th, 2020 at 12:15 am
如果觉得我的文章对你有用,请随意赞赏