centos7.6环境下安装python3.6.5

1.安装c语言编译和构建工具

yum install gcc

2.从python官网上找到python3.6.5的链接

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

3.把下载的文件解压缩,解压缩之后文件名为Python-3.6.5.tar

gunzip Python-3.6.5.tgz

4.把文件解归档

tar -xvf Python-3.6.5.tar

5.安装构建过程中可能需要用到的依赖库

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

6.进入python源代码目录,执行配置并生成Makefile (构建文件)

进入python源代码目录:cd Python-3.6.5

./configure --prefix=/usr/local/python36 --enable-optimizations

7.构建和安装

make && make install

8.创建软链接(快捷方式)

ln -s /usr/local/python36/bin/python3.6 /usr/bin/python3

ln -s /usr/local/python36/bin/pip3 /usr/bin/pip3

ln -s /usr/local/python36/bin/2to3-3.6 /usr/bin/2to3

9.检查是否安装成功

python3 --version

10.更新pip包管理工具

python3 -m pip install -U pip

你可能感兴趣的:(centos7.6环境下安装python3.6.5)