Skip to content
On this page

注意:

  • Python 3.8.2 (必须使用此版本)
  • Redis 5.0 +
  • Mysql 5.7 +

本文档拿 Centos 8 做演示

更新系统


shell
yum -y update

安装必要组件


shell
yum install -y gcc gcc-c++ automake autoconf libtool openssl-devel bzip2-devel libffi-devel make

下载 Python 3.8.2 && 解压压缩包


shell
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz && tar -zxvf Python-3.8.2.tgz && cd Python-3.8.2/

检测编译环境


shell
./configure prefix=/usr/local/python3 --enable-optimizations

编译安装


shell
make && make install

# 有时候一起执行会卡主,分开执行即可解决
make 
make install

设置软链接


shell
# 删除已经存在的软链接
rm -rf /usr/bin/python3 && rm -rf /usr/bin/pip3 && rm -rf /usr/bin/gunicorn3 && rm -rf /usr/bin/supervisord3 && rm -rf /usr/bin/supervisorctl3 && rm -rf /usr/bin/echo_supervisord_conf3

# 创建新的软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3 && ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 && ln -s /usr/local/python3/bin/gunicorn /usr/bin/gunicorn3 && ln -s /usr/local/python3/bin/supervisord /usr/bin/supervisord3 && ln -s /usr/local/python3/bin/supervisorctl /usr/bin/supervisorctl3 && ln -s /usr/local/python3/bin/echo_supervisord_conf /usr/bin/echo_supervisord_conf3

安装成功验证


shell
[root@VM-8-9-centos Python-3.8.2]# python3 -V && pip3 -V
Python 3.8.2
pip 19.2.3 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)