1. 准备工作

下载源码包

wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2

查看是否安装make工具

~#rpm -qa|grep make
automake-1.11.1-4.el6.noarch
make-3.81-20.el6.x86_64

如果没有安装make工具

yum -y install gcc automake autoconf libtool make

查看是否安装zlib库

~#rpm -qa|grep zlib
zlib-devel-1.2.3-29.el6.x86_64
zlib-1.2.3-29.el6.x86_64

安装zlib

yum install zlib-devel

检查是否安装ssl 库

~#rpm -qa|grep openssl
openssl-devel-1.0.1e-16.el6_5.x86_64
openssl-static-1.0.1e-16.el6_5.x86_64
openssl098e-0.9.8e-17.el6.centos.2.x86_64
openssl-1.0.1e-16.el6_5.x86_64
openssl-perl-1.0.1e-16.el6_5.x86_64

安装openssl

yum install openssl*

安装bzip2依赖库

yum install -y bzip2*

2. 编译安装

cp Python-2.7.3.tar.bz2 /usr/src/
tar -jxvf Python-2.7.3.tar.bz2
vi Modules/Setup.dist

找到

#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto
......
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz 

把注释去掉

编译

./configure --prefix=/usr/local/python2.7
make all
make install
make clean
make distclean

安装成功

~#/usr/local/python2.7/bin/python2.7
Python 2.7.3 (default, Dec 18 2013, 15:43:35)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
cd /usr/local/python2.7
python setup.py install

建立python2.7 软链

~#mv /usr/bin/python /usr/bin/python.bak
~#ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python2.7
~#ln -s /usr/bin/python2.7 /usr/bin/python

3. 解决yum无法使用的问题

~#yum update
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.3 (default, Dec 18 2013, 15:43:35)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq

因为centos 6.4 下yum默认使用的是python2.6

vi /usr/bin/yum
----------------------------------------------------
#!/usr/bin/python
import sys
try:
import yum
except ImportError:
.......

修改为

#!/usr/bin/python2.6
........

4. 安装python-pip工具

先安装setup-tools

wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg  --no-check-certificate
chmod +x setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg

安装pip

wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz --no-check-certificate
cp pip-1.3.1.tar.gz /usr/src/
tar zxvf pip-1.3.1.tar.gz
cd pip-1.3.1
python setup.py install
ln -s /usr/local/python2.7/bin/pip /usr/bin/pip

Centos 6.4 安装Python 2.7 python-pip的更多相关文章

  1. 转: CentOS 6.4安装pip,CentOS安装python包管理安装工具pip的方法

    from: http://www.linuxde.net/2014/05/15576.html CentOS 6.4安装pip,CentOS安装python包管理安装工具pip的方法 2014/05/ ...

  2. Linux CentOS 编绎安装Python 3.5

    Linux CentOS 编绎安装Python 3.5 先决条件(若无安装,则不能编绎使用idle3):yum install tk-devel xz -d Python-3.5.0.tar.xzta ...

  3. CentOS 6 下安装Python 3

    可以下载各个版本的python:https://www.python.org/ftp/python/ 配置安装 下载最新的安装包(截止2013/11/05),还是3.3.2版本. #wget http ...

  4. CentOS 6.4安装pip,CentOS安装python包管理安装工具pip的方法

    CentOS 6.4安装pip,CentOS安装python包管理安装工具pip的方法如下: 截至包子写本文的时候,pip最新为 1.5.5 wget --no-check-certificate h ...

  5. Python之——CentOS 6.5安装Python2.7.14

    Python之——CentOS 6.5安装Python2.7.14   版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/l1028386804/art ...

  6. CentOS下编译安装python包管理安装工具pip教程

    ubuntu 安装pip 代码如下: apt-get install python-pip 安装requests, pip install requests 对于centos的,直接 yum inst ...

  7. Centos 7.2 安装 Python 3.5(适用于Python 3所有版本安装)

    提示:我们必须不能破坏系统的环境.因为几个关键的应用程序依赖于Python 2.7.5(centos 7默认版本).如果替换了系统的Python环境就会发生很多难以预见的错误,甚至要重装系统. 安装前 ...

  8. CENTOS 7 升级安装 Python 3.5

    写在前面的话 本文采取源码的方式安装 Python 3.5.2,如果是其它版本会有或多或少的差异,且写这篇的时候官网最新的是 Python 3.7,个人使用 3.5 就足够了,没必要更新到最新,否则出 ...

  9. CentOS 6.9编译安装Python-2.7.14(python升级)

    参考 Python官网:https://www.python.org/ 阿里云 https://www.aliyun.com/jiaocheng/517192.html 一.查看CentOS版本和系统 ...

随机推荐

  1. 使用docker部署springboot应用

    1.构造Dockerfile打包文件 # from base image centos FROM centos #MAINTAINER lirenqing #Java Version #ENV JAV ...

  2. js数组操作-最佳图解

    js数组操作-最佳图解

  3. Virtualbox 虚拟机安装Linux

    背景:Win10系统   MSI主板 目标:基于Win10 利用虚拟机Virtualbox安装Linux 准备工作:Ctrl+Alt+Del打开任务管理器——>性能(查看CPU虚拟化是否开启) ...

  4. 微信小程序之点击列表的item带参数跳转界面

    1.在js文件里写个界面跳转的事件处理函数gotableinfo,var index = parseInt(e.currentTarget.dataset.index); 为获取当前点击列表的下脚标, ...

  5. Go获取美元实时汇率

    package main import ( "encoding/json" "fmt" "io/ioutil" "net/http ...

  6. 【Spring框架】<mvc:default-servlet-handler/>的作用

    优雅REST风格的资源URL不希望带 .html 或 .do 等后缀.由于早期的Spring MVC不能很好地处理静态资源,所以在web.xml中配置DispatcherServlet的请求映射,往往 ...

  7. Elasticsearch2.3.4使用手册(使用存储过程做增量同步的探索)

    一.工具安装 访问官网https://www.elastic.co/downloads/elasticsearch和http://xbib.org/repository/org/xbib/elasti ...

  8. 使用django发布带图片的网页(上)

    如何使用django发布带静态图片的网页呢? 在settings.py里加入下面内容 STATIC_ROOT = os.path.join(os.path.dirname(__file__),'sta ...

  9. 批量镜像locator(比如表情模板)

    #外挂   镜像loc     前缀  lf  镜像给   rt   选中其中一个会镜像另一个 myPrefix='lf_'myMdf='rt_' myselectLoc=mc.ls(sl=1)for ...

  10. node环境下express路由,

    1.基本路由概念 路由是指确定应用程序如何响应对特定端点的客户端请求,该请求是URI(或路径)和特定HTTP请求方法(GET,POST等). 每个路由都可以有一个或多个处理函数,这些函数在路由匹配时执 ...