系统:CentOS Linux release 7.7.1908 (Core)
软件:Python-3.6.7
安装步骤:
mkdir -p /usr/local/soft/package
cd /usr/local/soft/package
#下载安装包,解压
wget https://mirrors.huaweicloud.com/python/3.6.7/Python-3.6.7.tgz
tar -xzvf Python-3.6.7.tgz
cd Python-3.6.7
#编译依赖安装
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
#编译链接安装
./configure --prefix=/usr/local/soft/python3.6
make
#make的时候没有直接成功,按照提示执行以下类似语句再make:
#sed -e "s,@EXENAME@,/usr/local/soft/python3.6/bin/python3.6m," < ./Misc/python-config.in >python-config.py
#make
make install
#创建软连接
ln -s /usr/local/soft/python3.6/bin/python3.6 /usr/local/bin/python3
ln -s /usr/local/soft/python3.6/bin/pip3.6 /usr/local/bin/pip3
配置pip源:
vim ~/.pip/pip.conf
#添加以下内容
'''
[global]
index-url=https://mirrors.huaweicloud.com/repository/pypi/simple
[install]
trusted-host=mirrors.huaweicloud.com
'''
测试
pip3 --version
python3 --version
#升级pip
python3 -m pip install --upgrade pip