码迷,mamicode.com
首页 > 编程语言 > 详细

CentOS安装python3

时间:2018-12-27 13:24:57      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:usr   href   修改   python   cap   bzip2   源码   bin   python3   

步骤详情

1、CentOS安装Python的依赖包

yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
.
.

2、下载Python3X的源码包并编译

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
./configure --prefix=/usr/local/python36
yum -y install zlib* openssl-devel
make && make install
.
.

3、把#! /usr/bin/python修改为#! /usr/bin/python2

sed -i ‘s/#!/usr/bin/python/#!/usr/bin/python2.6/‘ /usr/bin/yum
(可选)sed -i ‘s/#! /usr/bin/python/#! /usr/bin/python2/‘ /usr/libexec/urlgrabber-ext-down
.
.

4、把/usr/bin/下的python2替换成python3

mv /usr/bin/python /usr/bin/pythonold
cp /usr/local/python36/bin/python3.6 /usr/bin/python
cp /usr/local/python36/bin/pip3 /usr/bin/pip3
.
.

写成shell脚本执行

#1、CentOS安装Python的依赖包
yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

#2、下载Python3X的源码包并编译
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
./configure --prefix=/usr/local/python36
yum -y install zlib* openssl-devel
make && make install

#3、把#! /usr/bin/python修改为#! /usr/bin/python2
sed -i ‘s/#!\/usr\/bin\/python/#!\/usr\/bin\/python2.6/‘ /usr/bin/yum
#(可选)sed  -i    ‘s/\#\! \/usr\/bin\/python/\#\! \/usr\/bin\/python2/‘   /usr/libexec/urlgrabber-ext-down

#4、把/usr/bin/下的python2替换成python3
mv /usr/bin/python /usr/bin/pythonold
cp /usr/local/python36/bin/python3.6 /usr/bin/python
cp /usr/local/python36/bin/pip3 /usr/bin/pip3

CentOS安装python3

标签:usr   href   修改   python   cap   bzip2   源码   bin   python3   

原文地址:https://www.cnblogs.com/Christal-R/p/10184242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!