安装python3 需要的依赖
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 libffi-devel wget gcc gcc-c++ automake autoconf libtool make
官网下载对应版本
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
解压下载的包
tar -zxf Python-3.8.12.tgz
配置、编译、安装
- cd Python-3.8.12
- ./configure --with-ssl --prefix=/opt/soft/python3.8.12
- make
- make install
设置链接,校验
- cd /usr/bin
- ln -s /opt/soft/python3.8.12/bin/python3.8 python3
- ln -s /opt/soft/python3.8.12/bin/pip3 pip3
- pip3 -V
- python3 -V
设置pip国内源
- mkdir ~/.pip
- cd ~/.pip
- vi pip.conf
[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
更新pip
python3 -m pip install --upgrade pip
评论区