Python3.6.5安装

Python3.6.5安装

Scroll Down

安装依赖环境

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

安装gcc编译器

yum install gcc -y

下载python安装包

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
(当然可以到官网去下载原码)

将安装包移动到/usr/local 文件夹下

mv Python-3.6.5.tgz /usr/local/
(我为了省事,直解在root 账户下安装的,如果您不是用的root,记着自己Python-3.6.5.tgz下载到的目录,然后再做移动)

在local目录下创建python3目录

mkdir /usr/local/python3

进入Python-3.6.5.tgz所在的目录下解压

cd /usr/local/
tar -xvf Python-3.6.5.tgz

进入文件夹Python-3.6.5

cd /usr/local/Python-3.6.5/

编译安装

#配置安装目录
./configure --prefix=/usr/local/python3
#编译原码
make
#执行源码安装
make install
#创建python软链接
ln -s /usr/local/python3/bin/python3  /usr/bin/python3
#创建pip软链接
ln -s  /usr/local/python3/bin/pip3.6  /usr/bin/pip3
python3 -V
Python 3.6.5
pip3 -V
pip 19.3.1 from /usr/local/python3/lib/python3.6/site-packages/pip (python 3.6)