Linux 安装 Python 2.7.10 和 3.5.0


    同一个系统安装多个 python 版本,不影响系统自带版本。

# 安装 Python 2.7.10
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
tar xzvf Python-2.7.10.tgz
mkdir /usr/local/python27
cd Python-2.7.10
./configure --prefix=/usr/local/python27
make
make install
ln -s /usr/local/python27/bin/python /usr/bin/python27

# 安装 Python 3.5.0
# 3.5.0 默认会安装 pip 工具,因为其它两个版本也安装了 pip ,所以需要添加软链接区分各个版本的 pip
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
tar xzvf Python-3.5.0.tgz
mkdir /usr/local/python35
cd Python-3.5.0
./configure --prefix=/usr/local/python35
make
make install
ln -s /usr/local/python35/bin/python3.5 /usr/bin/python35
ln -s /usr/local/python35/bin/pip3.5 /usr/bin/pip35


# 默认 python 进入自带版本,python27 进入自定义版本
[root@payun ~]# python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@payun ~]# 
[root@payun ~]# python27
Python 2.7.10 (default, Oct  4 2015, 17:50:54) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@payun ~]# python35
Python 3.5.0 (default, Oct  6 2015, 10:17:03) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>


转载于:https://my.oschina.net/payun/blog/513472

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值