简体   繁体   English

使用easy_install安装pip

[英]Installing pip using easy_install

I don't have root access and i want to install python from scratch. 我没有root访问权限,我想从头开始安装python。 So I downloaded the python source code and compiled it. 所以我下载了python源代码并编译了它。 Next I wanted to install pip . 接下来我想安装pip But when I ran python get-pip.py I got this error: 但是当我运行python get-pip.py了这个错误:

ImportError: cannot import name HTTPSHandler

Not having root access then I couldn't install stuff needed. 没有root访问权限,我无法安装所需的东西。 So I thought maybe I can install pip with easy_install so I went and installed setuptools which has easy_install . 所以我想也许我可以安装pipeasy_install ,所以我去,并安装setuptools具有easy_install But when I run easy_install pip I get this error: 但是当我运行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')

So now how to install pip ? 那么现在如何安装pip I'm really going crazy! 我真的疯了!

Edit: I can't use virutalenv 编辑:我不能使用virutalenv

try this to install pip : "easy_install-2.7 -U --user pip" 试试这个来安装pip:“easy_install-2.7 -U --user pip”

**another important info** 

To install pip on Ubuntu, Debian or Linux Mint: 在Ubuntu,Debian或Linux Mint上安装pip:

$ sudo apt-get install python-pip

To install pip on Fedora: 在Fedora上安装pip:

$ sudo yum install python-pip

To install pip on CentOS, first enable EPEL repository, and then run: 要在CentOS上安装pip,首先启用EPEL存储库,然后运行:

$ sudo yum install python-pip

To install pip on Archlinux: 在Archlinux上安装pip:

$ sudo pacman -S python-pip

This isn't precisely answering original question but if you're unfortunate enough to be trying to install pip with easy_install on centos6, I hope this helps. 这不是回答原始问题,但如果你不幸尝试在centos6上使用easy_install安装pip ,我希望这会有所帮助。

This used to work but now fails with below error: 这曾经工作但现在失败,出现以下错误:

$ 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')

I guess http://pypi.python.org got serious about requiring https . 我想http://pypi.python.org认真对待要求https If you make this little hack then easy_install pip works. 如果你做这个小黑客,那么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

For those who have no root access , here is how I solved the issue. 对于那些没有root访问权限的人来说 ,这就是我解决问题的方法。

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

  2. Unzip and cd to the Python source directory. 解压缩并cd到Python源目录。

  3. Configure with the "--with-ensurepip=install" flag, eg, 配置“--with-ensurepip = install”标志,例如,

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

  5. Now you should have a working but out-dated pip. 现在你应该有一个工作但过时的点子。 To get the latest pip, download the get-pip.py file and run python get-pip.py 要获取最新的pip,请下载get-pip.py文件并运行python get-pip.py

Now you should have the latest pip. 现在你应该有最新的点子。 Enjoy. 请享用。 :) :)

Virtualenv to the rescue! Virtualenv救援! It comes with pip, doesn't require root access, and allows you to have different environments each with their own copy of python, pip, and modules. 它带有pip,不需要root访问权限,并允许你拥有不同的环境,每个环境都有自己的python,pip和模块副本。 The installation docs list several installation methods, you want the last one called "Use locally from source". 安装文档列出了几种安装方法,您希望最后一种称为“从源本地使用”。 Please also have a look at virtualenvwrapper , which is just a set of shell scripts that makes working with virtualenv easier. 还请看一下virtualenvwrapper ,它只是一组shell脚本,可以更轻松地使用virtualenv。 Google will produce ample tutorials on both of these. 谷歌将为这两个产生丰富的教程。

pip installation is concern confirm with your python version in my case im using python3 so i use following command and it works . pip安装是关注确认你的python版本在我的情况下我使用python3所以我使用以下命令,它的工作原理。 let's try this 我们来试试吧

i am using MacOS 我正在使用MacOS

$ python3 get-pip.py $ python3 get-pip.py

Gave me lot of trouble too but this worked for me: 给我带来了很多麻烦,但这对我有用:

python3 get-pip.py python3 get-pip.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM