欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos7安装python3

程序员文章站 2022-05-29 12:10:37
...

 

然后更改pip源到阿里

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

生成缓存

yum makecache

下载python3

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

解压压缩包

tar -zxvf  Python-3.6.2.tgz -C /tmp

进入目录

cd /tmp/Python-3.6.2/

安装python3的依赖

yum -y groupinstall "Development tools"
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

编译安装python3

./configure --prefix=/usr/local/python3

make&make install

创建软链接

ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3

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