官网下载python3压缩包
链接: link.
百度云盘下载安装包
链接: link.
提取码:ttzs
#安装配置编译安装依赖环境
yum -y install gcc gcc-c++ make zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel
#解压压缩包
tar -xf Python-3.7.6.tar.xz
#进入解压后的目录
cd Python-3.7.6
#正则修改配置问价
sed -ri 's/^#readline/readline/' Modules/Setup.dist
sed -ri 's/^#(SSL=)/\1/' Modules/Setup.dist
sed -ri 's/^#(_ssl)/\1/' Modules/Setup.dist
sed -ri 's/^#([\t]*-DUSE)/\1/' Modules/Setup.dist
sed -ri 's/^#([\t]*-L\$\(SSL\))/\1/' Modules/Setup.dist
#配置
./configure --enable-shared
#编译并且安装
make && make install
#配置环境
file="/etc/profile.d/python3_lib.sh"
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' >$file
path="/usr/local/lib/"
file2="/etc/ld.so.conf.d/python3.conf"
echo $path > $file2
#执行如下命令使配置环境生效
ldconfig
source /etc/profile
#查看python版本
[root@localhost ~]# python3 -V
Python 3.7.6
#说明python3安装完成
配置使用本地的源安装第三方模块
#创建隐藏文件
mkdir ~/.pip
#执行命令,写入国内源
echo '[global]' >> ~/.pip/pip.conf
c1="index-url=https://mirrors.aliyun.com/pypi/simple"
echo "${c1}" >> ~/.pip/pip.conf
#升级pip3版本
pip3 install --upgrade pip
#安装ipython模块
pip3 install ipython