说明:全部操作都在root用户下执行,python3.7安装在/root/python3目录下
1.安装编译相关工具
yum -y groupinstall "Development tools"
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
yum install libffi-devel -y
2.下载安装包并解压
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvf Python-3.7.0.tar.xz
3.编译安装
先创建安装目录
mkdir /root/python3
cd Python-3.7.0
./configure --prefix=/root/python3 --enable-shared --with-ssl --enable-optimizations
make && make install
4.创建软连接
ln -s /root/python3/bin/python3 /usr/local/bin/python3
ln -s /root/python3/bin/pip3 /usr/local/bin/pip3
5.将python3安装路径写入环境变量
vi /etc/profile
最后一行加上
PYTHON_NAME=/root/python3
保存退出
source /etc/profile
6.将python库的路径写到/etc/ld.so.conf配置中
cd /etc/ld.so.conf.d
vi python3.conf
/root/python3/lib
ldconfig
标签:bin,etc,安装,devel,Centos7,Python3.7,3.7,root,python3
From: https://www.cnblogs.com/jzm123/p/17259062.html