- 安装依赖
[root@anson ~] yum -y install zlib-devel bzip2-devel openssl-devel openssl-static ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel lzma gcc
下载压缩包
3.7的版本最为稳定,所以下载了3.7.12
https://www.python.org/downloads/source/安装
[root@anson ~]# tar xvf Python-3.7.12.tar.xz
[root@anson ~]# mv Python-3.7.12 /usr/local/python-3.7.12
[root@anson ~]# cd /usr/local/python-3.7.12/
[root@anson python-3.7.12]# ./configure --prefix=/usr/local/sbin/python-3.7.12
[root@anson python-3.7.12]# make && make install
# 安装成功
Installing collected packages: setuptools, pip
Successfully installed pip-20.1.1 setuptools-47.1.0
- 配置环境
[root@anson python-3.7.12]# ln -sv /usr/local/sbin/python-3.7.12/bin/python3 /usr/bin/python3
[root@anson python-3.7.12]# python3 -V
Python 3.7.12
‘/usr/bin/python3’ -> ‘/usr/local/sbin/python-3.7.12/bin/python3’
[root@anson python-3.7.12]# ln -s /usr/local/sbin/python-3.7.12/bin/pip3 /usr/bin/pip3
[root@anson python-3.7.12]# pip3 -V
pip 20.1.1 from /usr/local/sbin/python-3.7.12/lib/python3.7/site-packages/pip (python 3.7)