Python官网:https://www.python.org/
下载指定版本的软件包:
[[email protected] data]# yum clean all && yum repolist #配置yum源,以便安装依赖软件包
[[email protected] data]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel gcc gcc-c++
#安装依赖,其中readline-devel包是防止在新安装的环境中不能使用方向键的问题
[[email protected] data]# wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
#下载指定版本的python源码包
[[email protected] data]# tar xvf Python-3.6.6.tar.xz #解压安装包
[[email protected] data]# cd Python-3.6.6/
[[email protected] Python-3.6.6]# ./configure --prefix=/usr/local/python3 #安装到指定目录中
[[email protected] Python-3.6.6]# make && make install #安装完成显示如下
[[email protected] Python-3.6.6]# ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3 #将python3添加到环境变量
[[email protected] python3]# ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
#将pip也添加到环境变量
查看pip的版本号
安装后可能遇到的小trouble
当我们为安装成功Python3而开心兴奋之时,我们发现我们的方向键无法使用了,如下图所示,解决方案是安装readline-devel软件包
原文地址:https://www.cnblogs.com/scaven-01/p/11395816.html