Centos7下简单安装python3
程序员文章站
2022-05-29 12:11:31
...
一、安装编译工具
#yum -y install gcc
#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 -y install libffi-devel
二、下载python3
#wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
#tar -Jxvf Python-3.7.0.tar.xz
注:tar.xz文件解压方法
#xz -d ***.tar.xz
#tar -xvf ***.tar
或者:
#tar Jxvf ***tar.xz
三、编译安装
#mkdir /usr/local/python3 创建编译安装目录
#cd Python-3.7.0
#./configure --prefix=/usr/local/python3
#make 编译
#make test 测试
#make install 编译安装
四、创建软链接
#mv /usr/bin/python /usr/bin/python.bak
#ln -s /root/Python-3.7.0/python /usr/bin/python
最后测试
#python -V
注:
#vim /usr/libexec/urlgrabber-ext-down
需要将第一行的python改为python2否则运行yum时会报错