Python 使用 easy_install 安装 pip

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26279207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:19:38  来源:igfitidea点击:

Installing pip using easy_install

pythonpipeasy-install

提问by Hyman Twain

I don't have root access and i want to install python from scratch. So I downloaded the python source code and compiled it. Next I wanted to install pip. But when I ran python get-pip.pyI got this error:

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

ImportError: cannot import name HTTPSHandler

ImportError: cannot import name HTTPSHandler

Not having root access then I couldn't install stuff needed. So I thought maybe I can install pipwith easy_installso I went and installed setuptoolswhich has easy_install. But when I run easy_install pipI get this error:

没有 root 访问权限,那么我无法安装所需的东西。所以我想也许我可以安装pipeasy_install所以我去安装setuptoolseasy_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')

So now how to install pip? I'm really going crazy!

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

Edit: I can't use virutalenv

编辑:我不能使用 virutalenv

回答by Priyank

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

回答by ErlVolton

Virtualenv to the rescue! 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. The installation docslist 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. Google will produce ample tutorials on both of these.

Virtualenv 来救援!它带有 pip,不需要 root 访问权限,并允许您拥有不同的环境,每个环境都有自己的 python、pip 和模块副本。 安装文档列出了几种安装方法,您需要最后一种称为“从源本地使用”。还请查看virtualenvwrapper,它只是一组 shell 脚本,可以更轻松地使用 virtualenv。谷歌将制作关于这两者的大量教程。

回答by user1036719

For those who have no root access, here is how I solved the issue.

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

  1. Download Python (Gzipped source tarball).

  2. Unzip and cd to the Python source directory.

  3. Configure with the "--with-ensurepip=install" flag, e.g.,

    ./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.pyfile and run python get-pip.py

  1. 下载 Python(Gzipped 源 tarball)。

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

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

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

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

Now you should have the latest pip. Enjoy. :)

现在您应该拥有最新的 pip。享受。:)

回答by jamshid

This isn't precisely answering original question but if you're unfortunate enough to be trying to install pipwith easy_installon centos6, I hope this helps.

这不正是回答原来的问题,但如果你不幸足以试图安装pipeasy_install上centos6,我希望这有助于。

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.orggot serious about requiring https. If you make this little hack then easy_install pipworks. sed --in-place 's#http://pypi.python.org#https://pypi.python.org#g' /usr/lib/python2.6/site-packages/setuptools/command/easy_install.py

我猜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

回答by user9856426

pip installation is concern confirm with your python version in my case i m using python3 so i use following command and it works . let's try this

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

i am using MacOS

我正在使用 MacOS

$ python3 get-pip.py

$ python3 get-pip.py

回答by AHBarrie

Gave me lot of trouble too but this worked for me:

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

python3 get-pip.py

python3 get-pip.py