Python3下载地址:官网地址
蓝奏云下载地址:Python-3.7.12及依赖包
一、环境
- 系统:CentOS 7
- 用户:ROOT
- Python版本:python3.7.12
二、安装
- 登录到centOS机器,新建文件夹
mkdir -p /usr/local/python3
- 将安装包和依赖包里的文件上传至/usr/local/python3
-
进入目录
cd /usr/local/python3/
- 安装依赖
# 如遇到安装失败,可以添加强制安装参数 --nodeps --force
例: rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm --nodeps --force
#安装依赖包 zlib-devel
rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
#安装依赖包 bzip2-devel
rpm -ivh bzip2-devel-1.0.6-13.el7.x86_64.rpm
#安装依赖包 epel-release
rpm -ivh epel-release-7-11.noarch.rpm
#安装依赖包 ncurses-devel
rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
# 安装依赖包 gcc(一定要按照以下的顺序进行安装)
rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm
rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm
rpm -ivh kernel-headers-3.10.0-514.el7.x86_64.rpm
rpm -ivh glibc-headers-2.17-157.el7.x86_64.rpm
rpm -ivh glibc-devel-2.17-157.el7.x86_64.rpm
rpm -ivh cpp-4.8.5-11.el7.x86_64.rpm
rpm -ivh gcc-4.8.5-11.el7.x86_64.rpm
# 安装依赖包 gcc-c+
rpm -ivh libstdc++-4.8.5-11.el7.x86_64.rpm
rpm -ivh libstdc++-devel-4.8.5-11.el7.x86_64.rpm
rpm -ivh gcc-c++-4.8.5-11.el7.x86_64.rpm
- 进行解压
tar -xzvf Python-3.7.12.tgz
- 进入解压路径
cd /usr/local/python3/Python-3.7.12
- 设置安装路径
./configure --prefix=/usr/local/python3.7 --enable-shared
make && make install
ln -s /usr/local/python3.7/bin/python3 /usr/bin/python3
echo "/usr/local/python3.7/lib" > /etc/ld.so.conf.d/python3.7.conf
ldconfig
- 检查Python3.7.12是否安装成功
python3 -V
显示如下图,说明成功;
- 删除安装包以及依赖包
rm -rf /usr/local/python3
三、安装Pip3
- python 3.7.12中自带了pip,所以只需要建立链接就行
ln -s /usr/local/python3.7/bin/pip3.7 /usr/bin/pip3
- 检查pip是否安装成功
pip3 -V