使用easy_install安装pip

时间:2014-10-09 13:06:14

标签: python pip easy-install

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

ImportError: cannot import name HTTPSHandler

没有root访问权限,我无法安装所需的东西。所以我想也许我可以使用pip安装easy_install所以我去安装了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

6 个答案:

答案 0 :(得分:16)

  

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

答案 1 :(得分:8)

这并不能正好回答原始问题,但如果您不幸尝试在centos6上使用pip安装easy_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

答案 2 :(得分:4)

对于那些无root权限的人,以下是我解决问题的方法。

  1. 下载Python(Gzipped源码tarball)。

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

  3. 配置" - with-ensurepip = install" flag,例如,

    ./configure --prefix=[your-specified-dir] --with-zlib-dir=/usr/lib64 --with-ensurepip=install
    
  4. make& make install

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

  6. 现在你应该有最新的点子。请享用。 :)

答案 3 :(得分:0)

Virtualenv救援!它带有pip,不需要root访问权限,并允许你拥有不同的环境,每个环境都有自己的python,pip和模块副本。 The installation docs列出了几种安装方法,您希望最后一种方法称为“从源本地使用”。另请参阅virtualenvwrapper,它只是一组shell脚本,可以更轻松地使用virtualenv。谷歌将为这两者提供大量的教程。

答案 4 :(得分:0)

pip安装是关注你的python版本确认我使用python3所以我使用以下命令,它的工作原理。让我们试试这个

我正在使用MacOS

$ python3 get-pip.py

答案 5 :(得分:0)

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

python3 get-pip.py

相关问题