linux python源码安装,Linux 源码安装Python

下载源码tar包

下载地址:https://www.python.org/downloads/

我这里下载的 Python-2.7.11.tgz

# tar -zxvf Python-2.7.11.tgz

进入解压缩后的文件夹

# cd Python-2.7.11

在编译前先在/usr/local建一个文件夹python2(作为python的安装路径,以免覆盖老的版本)

# mkdir /usr/local/python2

开始编译安装

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

# make

# make install

移动之前的版本

# mv /usr/bin/python /usr/bin/python_old

再建立新版本python的链接

ln -s /usr/local/python2/bin/python /usr/bin/python

这个时候输入

# python

Python 2.7.11 (default, Feb 19 2016, 18:01:00)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>>

完成

由于安装了新版的Python对yum 使用受到影响,情况如下

# yum grouplist

There was a problem importing one of the Python modules

required to run yum. The error leading to this problem was:

No module named yum

Please install a package which provides this module, or

verify that the module is installed correctly.

It's possible that the above module doesn't match the

current version of Python, which is:

2.7.11 (default, Feb 19 2016, 18:01:00)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

If you cannot solve this problem yourself, please go to

the yum faq at:

http://yum.baseurl.org/wiki/Faq

意思是python版本不匹配,我们修改yum为老版本python就是了

查看原python位置

# whereis python

python: /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /usr/include/python2.7 /usr/share/man/man1/python.1.gz

# vim /usr/bin/yum

修改第一行 #!/usr/bin/python 为 #!/usr/bin/python2.7

ok.完成

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值