前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS安装python3

CentOS安装python3

作者头像
Christal_R
发布2019-01-02 13:03:22
9460
发布2019-01-02 13:03:22
举报
文章被收录于专栏:女程序员的日常

步骤详情

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脚本执行

代码语言:javascript
复制
#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
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-12-27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 步骤详情
    • 1、CentOS安装Python的依赖包
      • 2、下载Python3X的源码包并编译
        • 3、把#! /usr/bin/python修改为#! /usr/bin/python2
          • 4、把/usr/bin/下的python2替换成python3
          • 写成shell脚本执行
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档