DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Pyt

1. 安装python依赖包,主要是gcc编译环境

yum groupinstall "Development tools" -y

2.zlib解压缩包

yum install –y --setopt=protected_multilib=false gcc zlib zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel 
 

3,2. 使用源码方式编译安装python3,必须执行编译安装,否则在安装 Python 库依赖时会有麻烦

 

cd /usr/local/src
# 下载python3.8.1源码包
wget -c https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
# 解压源码包
tar -zxvf Python-3.8.1.tgz
cd Python-3.8.1
# 编译安装
./configure --prefix=/usr/local --enable-shared && make && make install

echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf
# 在缓存文件/etc/ld.so.cache中追加进指定目录下的共享库
ldconfig
# 对python3可执行文件建软连接
ln -sf /usr/local/bin/python3 /usr/bin/python3

这样就轻松解决上面的报错了

 

原教程

 

你可能感兴趣的:(服务器,python)