Centos7安装Python3的方法

下面介绍安装Python3的方法

首先安装依赖包

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

然后根据自己需求下载不同版本的Python3,我下载的是Python3.6.2

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

建立一个空文件夹

mkdir /usr/local/python3 

然后解压压缩包,进入该目录,安装Python3

tar -xvJf  Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --prefix=/usr/local/python3
make && make install

最后创建软链接

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

在命令行中输入python3测试

image

转载自:https://www.cnblogs.com/s-seven/p/9105973.html

你可能感兴趣的:(Centos7安装Python3的方法)