升级python2.6.6到python2.7导致pip命令不可用

服务器环境为Centos6.8,python为默认的2.6.6版本

1.升级python

python2.6.6 升级到python2.7.14,此处不再描述
可以参考如下文档升级:
https://blog.csdn.net/see_you_see_me/article/details/78550977

2.Python导致pip命令不可用

升级Python2.7导致使用pip等命令安装模块失败,报错如下:

#pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

解决办法可以参考下面的文档,此处也不在详细描述了:
http://linuxsogood.org/816.html

在一外个国人的网站上找到了解决方案:

#curl -O http://python-distribute.org/distribute_setup.py
#/usr/local/pyton2.7/bin/python distribute_setup.py

提示:distribute_setup.py这个脚本文件内容可以找我要

#/usr/local/python2.7/bin/easy_install pip
#/usr/local/python2.7/bin/pip -V
[[email protected] ~]#  /usr/local/python2.7/bin/python distribute_setup.py
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gz
Traceback (most recent call last):
  File "distribute_setup.py", line 537, in <module>
    sys.exit(main())
  File "distribute_setup.py", line 533, in main
    tarball = download_setuptools(download_base=options.download_base)
  File "distribute_setup.py", line 206, in download_setuptools
    src = urlopen(url)
  File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 548, in http_response
    ‘http‘, request, response, code, msg, hdrs)
  File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/python2.7/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: SSL is required

[[email protected] ~]# grep DEFAULT_URL distribute_setup.py
DEFAULT_URL = "https://pypi.python.org/packages/source/d/distribute/"
修改此处的地址为:https

[[email protected] ~]#  /usr/local/python2.7/bin/python distribute_setup.py
。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。
Installing easy_install script to /usr/local/python2.7/bin
Installing easy_install-2.7 script to /usr/local/python2.7/bin

Installed /usr/local/python2.7/lib/python2.7/site-packages/distribute-0.6.49-py2.7.egg
Processing dependencies for distribute==0.6.49
Finished processing dependencies for distribute==0.6.49
After install bootstrap.
Creating /usr/local/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info
Creating /usr/local/python2.7/lib/python2.7/site-packages/setuptools.pth
[[email protected] ~]# echo $?
0
[[email protected] ~]# find / -name ‘easy_install‘
/usr/local/python2.7/bin/easy_install
/usr/bin/easy_install

使用新版本的python来运行这个脚本,这个会自动安装出来一个easy_install,然后使用这个新的easy_install来安装pip就可以了!

3.安装pip报错Could not find suitable distribution for Requirement.parse(‘pip‘)

error: Could not find suitable distribution for Requirement.parse(‘pip‘)

[[email protected] ~]# /usr/local/python2.7/bin/easy_install pip
Searching for pip
Reading http://pypi.python.org/simple/pip/
Couldn‘t find index page for ‘pip‘ (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse(‘pip‘)

解决文档:https://blog.csdn.net/sunnywuxian/article/details/82870803
解决文档:https://pip.readthedocs.io/en/stable/installing/
解决过程如下:

[[email protected] ~]# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
[[email protected] ~]# python get-pip.py
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won‘t be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pip
  Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 151kB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/96/ba/a4702cbb6a3a485239fbe9525443446203f00771af9ac000fa3ef2788201/wheel-0.33.1-py2.py3-none-any.whl
Installing collected packages: pip, wheel
  The script wheel is installed in ‘/usr/local/python2.7/bin‘ which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-19.0.3 wheel-0.33.1
[[email protected] ~]# /usr/local/python2.7/bin/easy_install pip
Searching for pip
Best match: pip 19.0.3
Adding pip 19.0.3 to easy-install.pth file
Installing pip script to /usr/local/python2.7/bin
Installing pip3.7 script to /usr/local/python2.7/bin
Installing pip3 script to /usr/local/python2.7/bin

Using /usr/local/python2.7/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
[[email protected] ~]# echo $?
[[email protected] ~]#  /usr/local/python2.7/bin/pip -V
pip 19.0.3 from /usr/local/python2.7/lib/python2.7/site-packages/pip (python 2.7)
[root[email protected] ~]# 

到此处pip命令成功安装

原文地址:https://blog.51cto.com/wujianwei/2376898

时间: 2024-10-01 11:16:59

升级python2.6.6到python2.7导致pip命令不可用的相关文章

centos6.5 由`GLIBC_2.4&#39; not found后导致所有命令不可用的问题

今天安装oracle 数据库,安装时 有两个依赖包需要安装分别为 compat-libstdc++-33-3.2.3-61.i386.rpm glibc-2.3.4-2.41.x86_64.rpm 于是就百度一下安装了起来: [[email protected] ~]# rpm -ivh *.rpm warning: compat-libstdc++-33-3.2.3-61.i386.rpm: Header V3 DSA/SHA1 Signature, key ID e8562897: NOKE

修改/etc/profile导致常用命令不可用的解决办法

原因:/etc/profile文件修改有误 解决办法: 用/usr/bin/vim /etc/profile进入,进去后修改正确/etc/profile,然后重启机器让该文件生效即可.

~/.bashrc文件写错, 导致Linux命令不可用

重新赋予环境变量PATH就行 export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin 原文地址:https://www.cnblogs.com/fuyusong/p/9325768.html

centos升级系统自带的python2.6为python2.7

转自:https://www.cnblogs.com/terryguan/p/7233801.html 查看当前系统中的 Python 版本 python --version 返回 Python 2.6.6 为正常. 检查 CentOS 版本 cat /etc/redhat-release 返回 CentOS release 6.9 (Final) 为正常. 安装所有的开发工具包 yum groupinstall -y "Development tools" 安装其它的必需包 yum

Centos6.5 python2.6.6升级2.7.13,安装setuptools和pip

1.安装Development Tools和相关编译安装的组件 # yum -y groupinstall "Development tools" # yum -y install openssl-devel zlib-devel ncurses-devel bzip2-devel readline-devel libtool-ltdl-devel sqlite-devel tk-devel tcl-devel 2.从搜狐镜像站下载并解压最新Python 2.7.13的源代码 # wg

解决python3与python2的pip命令冲突问题冲突(window版)

解决方法再上一篇有大概讲解: 这里做一些补充: 上一篇说过,删除python3和python2中的python.exe文件后关闭dos窗口,重新打开dos,就可以进行安装, 还有一种就是 如果python2下载requests包 Python2 -m pip install requests 这样通过Python2这个标识表明我们需要在python2中用pip安装requests包 Python3也是相同方式 Python3 -m pip install requests 注意事项:用pytho

【Python】同时安装了python2和python3时,pip命令该如何使用?

当python2和python3同时安装windows上时,它们对应的pip都叫pip.exe,所以不能够直接使用 pip install 命令来安装软件包. 而是要使用启动器py.exe来指定pip的版本. 命令如下: py -2 -m pip install xxxx    # -2 表示使用 Python2,-m pip 表示运行 pip 模块,也就是运行pip命令了. 如果是为Python3安装软件,那么命令类似的变成 py -3 -m pip install xxxx 原文地址:htt

/lib64/libc.so.6 升级动态库导致所有命令不能使用

问题:一次安装软件,更改/lib64/libc.so.6导致所有命令都不能使用 注意:不要重启机器 解决步骤: 找一台相同的机器,先找出libc.so.6所在位置及其软连接哪个文件,如下 [[email protected] ~]# find / -name "libc.so.6" /lib64/libc.so.6 [[email protected] ~]# ll /lib64/libc.so.6 lrwxrwxrwx 1 root root 12 Mar  9  2016 /lib

全局变量导致所有命令都执行不了。

在配置MySQL时,做了个全局变量,少打了个"$"符号,导致所有命令都执行不了. 一开始我一直琢磨不出来为什么所有命令都执行不了. 如图: 要加个"$" 请用,命令全路径编辑/etc/profile: 输入: /usr/bin/vim /etc/profile 注意vim后有空格 然后将原来修改的内容删除 重新启动.shutdown -r now 或者reboot