当前最新的 CentOS 7默认安装的是 Python 2 ,并且默认的官方 yum 源中不提供 Python 3 的安装包,因此记录备用。
查看Python命令的位置
1 | [[email protected] ~]# whereis python |
安装Python3的相关依赖包
1 | yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make |
通过以上命令即可安装了python3所用的相关依赖。
下载Python3的源码包
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
编译
1 | tar -xf Python-3.6.4.tar.xz |
添加软链接
1 | #备份原来的链接 |
最后通过python -V
即可查看当前python版本为3.6。
参考:https://blog.csdn.net/lovefengruoqing/article/details/79284573