下载源码tar包下载地址:https://www.python.org/downloads/我这里下载的 Python-2.7.11.tgz# tar -zxvf Python-2.7.11.tgz进入解压缩后的文件夹# cd 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.完成
--结束END--
本文标题: Linux 源码安装Python
本文链接: https://lsjlt.com/news/190878.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0