标签:centos6.5中实现python2与python3的并存
linux下python的安装
安装步骤如下
1 准备编译环境
yum groupinstall ‘Development Tools‘
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel sqlit
2 下载 Python3.5代码包
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
3 编译
tar Jxvf Python-3.5.2.tar.xz
cd Python-3.5.2
./configure --prefix=/usr/local/python3
make && make install
4 设置环境变量
echo ‘export PATH=$PATH:/usr/local/python3/bin‘ >> ~/.bashrc
5 设置目录(这样做的目的是在系统任意目录敲入python3调用的是python3.5的命令)
mv /usr/bin/python /usr/local/python.bak
rm -rf /usr/local/python2
ln -sv /usr/local/python2.6 /usr/bin/python2
ln -sv /usr/local/python3/bin/python3.5 /usr/bin/python
6 修改yum脚本,使其指向旧版本的python,已避免yum无法运行
sed -i ‘s$#!/usr/bin/python$#!/usr/bin/python2.6$g‘ /usr/bin/yum
7 测试
输入python 显示如下
本文出自 “术业有专攻,如是而已” 博客,请务必保留此出处http://fustudy.blog.51cto.com/13154622/1961160
Centos6.5中实现python2与python3的并存
标签:centos6.5中实现python2与python3的并存
原文地址:http://fustudy.blog.51cto.com/13154622/1961160