安装依赖环境
代码语言:javascript复制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
下载python3
代码语言:javascript复制centos系统下安装
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
安装python3
代码语言:javascript复制//移动到一个合适的目录方便查找
mkdir -p /usr/local/python3
mv Python-3.7.1.tgz /usr/local/python3
//解压包
tar -zxvf Python-3.7.1.tgz
//指定编译位置,就是当前位置
./configure --prefix=/usr/local/python3
//安装
make && make install
//建立软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
//.bash_profile添加查找路径
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
//更新
source ~/.bash_profile
报错处理
代码语言:javascript复制1. ModuleNotFoundError: No module named '_ctypes
安装 yum install -y gcc
2. configure: error: no acceptable C compiler found in $PATH
安装 yum install -y libffi-devel
3. python链接已存在
改名 mv /usr/bin/python /usr/bin/python.bak