安装依赖包;
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc* make -y
去Python官网下载需要Python3.7.8
;
wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
将下载下来的Python上传到Linux服务器上:/usr/local/Python3
(这里的Python3
文件夹是自己创建的);
将Python进行解压;
# 切换到压缩包所在的目录 cd /usr/local/Python3 # 使用root权限进行解压 tar zxvf Python-3.7.8
配置安装路径
# 切入到解压目录 cd /usr/local/Python3/Python-3.7.8 # 配置安装路径 ./configure prefix=/usr/local/python3
编译安装
make && make install
配置软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
测试
# 看是否可以运行 python3 pip3
错误一:No module named '_ctypes'
yum install libffi-devel -y cd Python-3.7.8/ make clean && make && make install