centOS6.5 安装 python2.7 pip

目前大部分用户使用的CentOS6.5上默认的Python还是2.6版本。升级到Python2.7碰到很多问题。本文将介绍如何安装Python2.7。

安装python 依赖包:

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

下载安装Python2.7
python2.7 下载地址

https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz

安装python2.7

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
./configure --prefix=/usr/local --enable-shared
export  LD_LIBRARY_PATH=/usr/local/lib
make && make install

安装完成后,通过运行python,可以看到版本

#python --version
Python 2.7.12

安装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

安装setuptools

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

下载pip

wget https://pypi.python.org/packages/41/27/9a8d24e1b55bd8c85e4d022da2922cb206f183e2d18fee4e320c9547e751/pip-8.1.1.tar.gz#md5=6b86f11841e89c8241d689956ba99ed7
tar vxf pip-8.1.1.tar.gz 
cd pip-8.1.1
python setup.py install

安装完成后,运行pip

[root@crmnginx pip-8.1.1]# pip
Traceback (most recent call last):
  File "/usr/bin/pip2", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2927, in <module>
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2913, in _call_aside
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 637, in _build_master
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 650, in _build_from_requirements
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 829, in resolve
pkg_resources.DistributionNotFound: The 'pip==7.1.0' distribution was not found and is required by the application

报错原因:
现在的pip版本还是系统默认带的版本,需要新版本替代就版本

rm -rf /usr/bin/pip*
cp -r /usr/local/python2.7/bin/pip* /usr/bin/
[xxx@crmnginx pip-8.1.1]# 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.
  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.
  --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.
  --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.
You have new mail in /var/spool/mail/root

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值