yum update
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
wget https://www.python.org/ftp/3.7.0/Python-3.7.0.tgz
下载好了之后在文件所在目录解压
tar -xvf Python-3.7.0.tgz
进入到解压的python的目录里面,使用Python3.7.0/configure
文件进行配置
cd Python-3.7.0
./configure --prefix=/opt/python/python-3.7.0 --enable-shared --with-ssl
可选以下参数
./configure --enable-optimizations
make && make install
添加软链或者添加到环境变量,直接输入python3就可以使用了,下边是添加软连接:
ln -s /opt/python/python-3.7.0/bin/pip3 /usr/bin/
ln -s /opt/python/python-3.7.0/bin/python3 /usr/bin/
此步骤是为了解决
error while loading shared libraries: libpython3.7m.so.1.0:
解决办法:将lib添加至库配置信息中
cd /etc/ld.so.conf.d
vi python3.conf
/opt/python/python-3.7.0/lib
将编译后的python/lib地址加入conf文件
ldconfig