1.安装依赖包
1)首先安装gcc编译器,gcc有些系统版本已经默认安装,通过 gcc --version 查看,没安装的先安装gcc
yum -y install gcc
2)安装其它依赖包,(注:不要缺少,否则有可能安装python出错,python3.7.0以下的版本可不装 libffi-devel )
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 libffi-devel
2.点击下方链接下载Python3.7安装包
Python3.7.0安装包
提取码:rnw4
3.配置安装python3
1) 解压安装包到指定目录
tar -zxvf Python-3.7.0.tgz -C /usr/local/
2)新建一个空文件夹,用于存放python3程序
mkdir /usr/local/python3
3) 执行配置文件,编译,编译安装
cd /usr/local/Python-3.7.0/
./configure --prefix=/usr/local/python3
make && make install
安装完成没有提示错误便安装成功了
4)建立软连接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
4.验证安装是否成功
输入命令:
python3
出现:
Python 3.7.0 (default, Oct 29 2019, 23:04:03)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> ^C
KeyboardInterrupt
>>>
至此,安装完成。