1.查看centos版本
命令:lsb_release -a
结果:[root@iZ8vb57wa5ogqhb0k0y4v2Z ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.6.1810 (Core)
Release: 7.6.1810
Codename: Core
2.安装python3.6.7
1.安装c语言编译和构建工具
yum install gcc
2.从python官网上找到python3.6.7的链接
wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz
3.把下载的文件解压缩,解压缩之后文件名为Python-3.6.7.tar
gunzip Python-3.6.7.tgz
4.把文件解归档
tar -xvf Python-3.6.7.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.7
./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
作者:燃烧的火_10e3
链接:https://www.jianshu.com/p/7475fa297d8c
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。