CentOS 7.7安装python3.8

CentOS 7.7安装python3.8

下载python3.8 安装包

cd Downloads/

wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

安装编译需要的库

yum -y groupinstall "Development tools"
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
yum install libffi-devel -y

解压编译安装


tar -zxvf Python-3.8.1.tgz
cd Python-3.8.1
mkdir /usr/local/python3 
./configure --prefix=/usr/local/python3   (prefix表示安装的路径,我安装在/usr/local中,也可以安装其他地方)
make && make install

创建软连接

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

验证是否安装成功

python3 -V
pip3 -V

修改pip 源为阿里源或公司私有源

mkdir ~/.pip/
cd ~/.pip/
 vi pip.conf

添加如下内容

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

建议用户目录下都有这个

你可能感兴趣的:(Centos)