文章目录
Linux centos6 安装python2.7
1.下载源码包,后面的下载链接直接在python官网找的,如果想安装更高的版本自行更换
先下载好这些东西
yum install openssl-devel zlib-devel
- 1
在找到官网的Python-2.7.10.tgz
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
- 1
2.解压压缩包
tar xvf Python-2.7.10.tgz
- 1
3.指定安装路径
cd Python-2.7.10
./configure --prefix=/usr/local/python27
- 1
- 2
不行的话应该没下载gcc–>yum install -y gcc
4.编译并安装
make
make install
- 1
- 2
5.创建链接将python指向2.7版本
python默认是指向2.6版本的
删除原有的指向2.6的链接,创建新的链接指向2.7,执行python可以看到已经指向2.7版本了
rm -f /usr/bin/python
ln -s /usr/local/python27/bin/python /usr/bin/python
- 1
- 2
至此python已经安装好了,
可以查看python版本
python -V
- 1
还有要修改 /usr/bin/yum
将开头的#!/usr/bin/python
改成#!/usr/bin/python2.6
,因为centos只支持yum2.6的。
6.安装pip ,同样去python官网找的下载链接,需要setup-tools和pip两个包
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
wget https://pypi.python.org/packages/ff/d4/209f4939c49e31f5524fa0027bf1c8ec3107abaf7c61fdaad704a648c281/setuptools-21.0.0.tar.gz#md5=81964fdb89534118707742e6d1a1ddb4
- 1
- 2
解压压缩包
tar xvf pip-9.0.1.tar.gz
tar vxf setuptools-21.0.0.tar.gz
- 1
- 2
8.使用python进行安装
先安装setup-tools
cd setuptools-21.0.0
python setup.py install
- 1
- 2
安装成功之后再安装pip,进入pip目录,执行python setup.py install安装pip
cd pip-9.0.1
python setup.py install
- 1
- 2
安装成功之后创建pip的软链接
ln -s /usr/local/python27/bin/pip /usr/bin/pip
- 1
对了还要配置pip源,
在配置文件下~/.pip/pip.conf写下
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
- 1
- 2
- 3
- 4
如果没有该文件那就创建一个。。。
9.安装ansible
pip install ansible
- 1
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
<div class="more-toolbox">
<div class="left-toolbox">
<ul class="toolbox-list">
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">点赞</span>
<span class="count"></span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;" data-report-click="{"mod":"1582594662_002"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打赏开始-->
<!--打赏结束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章举报</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/weixin_46108954">
<img src="https://profile.csdnimg.cn/4/B/A/3_weixin_46108954" class="avatar_pic" username="weixin_46108954">
<img src="https://g.csdnimg.cn/static/user-reg-year/2x/0.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.csdn.net/weixin_46108954" data-report-click="{"mod":"popu_379"}" target="_blank">匡夆</a></span>
</div>
<div class="text"><span>发布了166 篇原创文章</span> · <span>获赞 34</span> · <span>访问量 9644</span></div>
</div>
<div class="right-message">
<a href="https://im.csdn.net/im/main.html?userName=weixin_46108954" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm attented bt-button personal-watch" data-report-click="{"mod":"popu_379"}">已关注</a>
</div>
</div>
</div>