1 安装依赖环境
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
2.下载Python3
mkdir /usr/local/tools
cd /usr/local/tools
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
3.安装python3
mkdir -p /usr/local/python3
tar -zxvf Python-3.7.3.tgz
4.进入解压后的目录,编译安装
编译安装前需要安装编译器yum install gcc
cd Python-3.7.3
./configure --prefix=/usr/local/python3
make && make install
5.建立python3的软链
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
6.并将/usr/local/python3/bin加入PATH
vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
6.gunicorn 启动项目报错:failed to run command ‘gunicorn’: No such file or directory,则运行下面命令
ln -s /usr/local/python3/bin/gunicorn /usr/bin/gunicorn