MENU

#教程#Centos7安装Pyton3

September 7, 2018 • Read: 2007 • 网络笔记

最近在使用Vultr的Centos7镜像,但是默认的Python是2.7版本,然而有点脚本需要Python3的支持。所以才有了这个半路子搜索出来的教程。

安装

首先我们需要更新最新的源

yum update -y

安装可存在的依赖

yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel zlib-devel

下载python源码包,地址为https://www.python.org/downloads/source/,然后通过xftp上传上去,或者直接使用wget命令,wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz下载到本地

tar -zxvf Python-3.6.1.tgz
cd Python-3.6.1/

把python3.6安装到/usr/local目录下

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

make 
make altinstall

更改/usr/bin/python链接

cd /usr/bin 
mv python python.backup 
ln -s /usr/local/bin/python3.6 /usr/bin/python 
ln -s /usr/local/bin/python3.6 /usr/bin/python3 
rm -rf /usr/bin/python2 
ln -s /usr/bin/python2.7 /usr/bin/python2
Archives QR Code Tip
QR Code for this page
Tipping QR Code