【问题标题】:Installing pip using easy_install使用 easy_install 安装 pip
【发布时间】:2014-12-04 10:19:24
【问题描述】:

我没有 root 访问权限,我想从头开始安装 python。所以我下载了python源代码并编译了它。接下来我想安装pip。但是当我运行python get-pip.py 时,我得到了这个错误:

ImportError: cannot import name HTTPSHandler

没有 root 访问权限,所以我无法安装所需的东西。所以我想也许我可以用easy_install 安装pip,所以我去安装了setuptools,它有easy_install。但是当我运行 easy_install pip 时,我得到了这个错误:

Searching for pip
Reading https://pypi.python.org/simple/pip/
Download error on https://pypi.python.org/simple/pip/: unknown url type: https -- Some packages may not be found!
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: unknown url type: https -- Some packages may not be found!
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')

那么现在如何安装pip?我真的要疯了!

编辑:我不能使用virutalenv

【问题讨论】:

标签: python pip easy-install


【解决方案1】:

也给我带来了很多麻烦,但这对我有用:

python3 get-pip.py

【讨论】:

    【解决方案2】:

    pip 安装是在我使用 python3 的情况下确认您的 python 版本,所以我使用以下命令并且它可以工作。让我们试试这个

    我正在使用 MacOS

    $ python3 get-pip.py

    【讨论】:

      【解决方案3】:

      这并不能准确回答原始问题,但如果您不幸尝试在 centos6 上安装 pipeasy_install,我希望这会有所帮助。

      这曾经可以工作,但现在失败并出现以下错误:

      $ docker run -ti centos:6 bash -c 'yum install -y python-setuptools && easy_install pip'
      ...
      Installed:
        python-setuptools.noarch 0:0.6.10-3.el6                                                                                                                       
      
      Complete!
      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')
      

      我猜http://pypi.python.org 对要求https 是认真的。 如果你做了这个小技巧,那么easy_install pip 就可以了。 sed --in-place 's#http://pypi.python.org#https://pypi.python.org#g' /usr/lib/python2.6/site-packages/setuptools/command/easy_install.py

      【讨论】:

      • 更糟的是,现在 centos6 用户需要坚持使用 pip 9.0.3。最新的(pip 10)打破了 centos 6.9 的兼容性,这似乎很疯狂,因为仍然支持 centos6 并且仍然有大量用户,并且默认情况下在 centos 上安装了 python。例如。 docker run -ti centos:6 bash -c 'yum install -y python-setuptools && easy_install pip==9.0.3 && pip install restnavigator'
      【解决方案4】:

      对于那些没有 root 访问权限的人,这是我解决问题的方法。

      1. 下载 Python(Gzip 压缩源代码 tarball)。

      2. 解压并 cd 到 Python 源目录。

      3. 使用“--with-ensurepip=install”标志进行配置,例如,

        ./configure --prefix=[your-specified-dir] --with-zlib-dir=/usr/lib64 --with-ensurepip=install
        
      4. 制作和制作安装

      5. 现在你应该有一个工作但过时的点。要获取最新的 pip,请下载 get-pip.py 文件并运行 python get-pip.py

      现在你应该有最新的点子了。享受。 :)

      【讨论】:

        【解决方案5】:

        Virtualenv 来救援!它带有 pip,不需要 root 访问权限,并且允许您拥有不同的环境,每个环境都有自己的 python、pip 和模块副本。 The installation docs 列出几种安装方法,您想要最后一种称为“从源代码本地使用”。还请查看virtualenvwrapper,它只是一组使使用 virtualenv 更容易的 shell 脚本。 Google 将针对这两个方面提供大量教程。

        【讨论】:

        • 为什么消极的爱?
        【解决方案6】:

        试试这个来安装 pip : "easy_install-2.7 -U --user pip"

        **another important info** 
        

        在 Ubuntu、Debian 或 Linux Mint 上安装 pip:

        $ sudo apt-get install python-pip
        

        在 Fedora 上安装 pip:

        $ sudo yum install python-pip
        

        要在 CentOS 上安装 pip,首先启用 EPEL 存储库,然后运行:

        $ sudo yum install python-pip
        

        在 Archlinux 上安装 pip:

        $ sudo pacman -S python-pip
        

        【讨论】:

        • 我没有root权限!
        • 你可以为 suse 添加 sudo zypper install python-pip