centos6.5升级python2.6到2.7 + 安装pip

目前大部分用户使用的CentOS6.5上默认的Python还是2.6版本,并且还不能卸载python2.6,很多系统组建需要依赖与python2.6,所以升级到python2.7会有点麻烦,在这里记录一下。

1、在安装python之前还需要安装一些依赖组件

安装过程将用到gcc库,我们可以直接安装

     yum install Development Tools

另外还需要一些额外的依赖包

     yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel

2、下载安装python2.7

可以直接从python官网上下载python, https://www.python.org/ftp/python/

选择你需要下载的版本,我这里下载2.7.11的最新版本

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar vxf Python-2.7.11.tgz
cd Python-2.7.11.tgz
./configure --prefix=/usr/local
make && make install

编译安装完成之后查看python的版本

>>> import sys
>>> sys.version
'2.7.11 (default, May  6 2016, 01:38:00) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]'


3.安装pip


  pip是python的安装工具,很多python的常用工具,都可以通过pip进行安装。

  要安装pip,首先要安装setuptools。下面的链接可以得到相关信息,最新版本是21.0.0:

  https://pypi.python.org/pypi/setuptools

  下载链接:

  https://pypi.python.org/packages/ff/d4/209f4939c49e31f5524fa0027bf1c8ec3107abaf7c61fdaad704a648c281/setuptools-21.0.0.tar.gz#md5=81964fdb89534118707742e6d1a1ddb4

同样的,进行安装:

tar vxf setuptools-21.0.0.tar.gz 
cd setuptools-21.0.0
python setup.py  install


安装完成后,下载pip。其信息在如下网站:

  https://pypi.python.org/pypi/pip

  最新版是9.0.1,下载链接: https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz.asc

  同样的,进行安装

tar vxf pip-9.0.1.tar.gz 
cd pip-9.0.1
python setup.py install
安装完成后,运行pip

[root@serversvn1 ~]# pip

Usage:   
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.

至此python和pip都已经安装完成







©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页