问题:为什么要在easy_install上使用pip?[关闭]

一条推文中写道:

不要使用easy_install,除非您喜欢对自己的脸部进行刺伤。使用点子。

为什么要在easy_install上使用pip?难道不是PyPI和程序包作者最主要的原因吗?如果作者将废话源tarball(例如:缺少文件,没有setup.py)上传到PyPI,则pip和easy_install都将失败。除了化妆品的差异,为什么Python的人(如上面的鸣叫)似乎强烈地倾向于在点子的easy_install?

(假设我们正在谈论由社区维护的Distribute软件包中的easy_install)

A tweet reads:

Don’t use easy_install, unless you like stabbing yourself in the face. Use pip.

Why use pip over easy_install? Doesn’t the fault lie with PyPI and package authors mostly? If an author uploads crap source tarball (eg: missing files, no setup.py) to PyPI, then both pip and easy_install will fail. Other than cosmetic differences, why do Python people (like in the above tweet) seem to strongly favor pip over easy_install?

(Let’s assume that we’re talking about easy_install from the Distribute package, that is maintained by the community)


回答 0

此处的许多答案在2015年已经过时了(尽管最初由Daniel Roseman接受的答案不是)。这是当前的状态:

  • 现在,二进制程序包以轮子(.whl文件)的形式分发-不仅在PyPI上,而且在第三方存储库中,例如Christoph Gohlke的Windows Extension Packagespip可以处理轮子;easy_install不能。
  • 虚拟环境(由3.4内置,或者可以通过2.6添加到2.6 + / 3.1 + )已经成为一个非常重要和突出的工具(并在官方文档中推荐);它们pip是开箱即用的,但是甚至无法正常使用easy_install
  • distribute包含的软件包easy_install不再维护。它的改进已setuptools合并回setuptools。尝试安装distribute只会安装setuptools
  • easy_install 本身只是准维护的。
  • 所有的其中箱子pip用于不如easy_install从解包源树-installing,从DVCS回购等-是早已过去的; 你可以pip install .pip install git+https://
  • pip带有来自python.org的官方Python 2.7和3.4+软件包,pip如果您从源代码构建,则默认情况下会包含引导程序。
  • Python打包用户指南》已取代了有关安装,使用和构建软件包的各种文档的不完整之处。现在,Python自己的有关安装Python模块的文档符合该用户指南的要求,并明确地pip称为“首选安装程序”。
  • pip这些年来,还添加了其他新功能,这些功能将永远不会存在easy_install。例如,pip通过构建需求文件,然后在每一侧使用单个命令安装它,可以轻松克隆站点程序包。或将您的需求文件转换为本地回购以用于内部开发。等等。

我知道easy_install在2015年使用的唯一好的理由是在OS X 10.5-10.8中使用Apple预先安装的Python版本的特殊情况。从10.5开始,Apple已包含easy_install,但从10.10开始,它们仍然不包含pip。使用10.9+时,您仍然应该只使用get-pip.py,但是对于10.5-10.8,这存在一些问题,因此更容易实现sudo easy_install pip。(通常,这easy_install pip是一个坏主意;您只想在OS X 10.5-10.8上才能做到这一点。)此外,10.5-10.8包含readline以一种easy_install知道如何纠缠而pip不会纠缠的方式,因此您也想sudo easy_install readline如果要升级。

Many of the answers here are out of date for 2015 (although the initially accepted one from Daniel Roseman is not). Here’s the current state of things:

  • Binary packages are now distributed as wheels (.whl files)—not just on PyPI, but in third-party repositories like Christoph Gohlke’s Extension Packages for Windows. pip can handle wheels; easy_install cannot.
  • Virtual environments (which come built-in with 3.4, or can be added to 2.6+/3.1+ with ) have become a very important and prominent tool (and recommended in the official docs); they include pip out of the box, but don’t even work properly with easy_install.
  • The distribute package that included easy_install is no longer maintained. Its improvements over setuptools got merged back into setuptools. Trying to install distribute will just install setuptools instead.
  • easy_install itself is only quasi-maintained.
  • All of the cases where pip used to be inferior to easy_install—installing from an unpacked source tree, from a DVCS repo, etc.—are long-gone; you can pip install ., pip install git+https://.
  • pip comes with the official Python 2.7 and 3.4+ packages from python.org, and a pip bootstrap is included by default if you build from source.
  • The various incomplete bits of documentation on installing, using, and building packages have been replaced by the Python Packaging User Guide. Python’s own documentation on Installing Python Modules now defers to this user guide, and explicitly calls out pip as “the preferred installer program”.
  • Other new features have been added to pip over the years that will never be in easy_install. For example, pip makes it easy to clone your site-packages by building a requirements file and then installing it with a single command on each side. Or to convert your requirements file to a local repo to use for in-house development. And so on.

The only good reason that I know of to use easy_install in 2015 is the special case of using Apple’s pre-installed Python versions with OS X 10.5-10.8. Since 10.5, Apple has included easy_install, but as of 10.10 they still don’t include pip. With 10.9+, you should still just use get-pip.py, but for 10.5-10.8, this has some problems, so it’s easier to sudo easy_install pip. (In general, easy_install pip is a bad idea; it’s only for OS X 10.5-10.8 that you want to do this.) Also, 10.5-10.8 include readline in a way that easy_install knows how to kludge around but pip doesn’t, so you also want to sudo easy_install readline if you want to upgrade that.


回答 1

从伊恩·比金(Ian Bicking)自己对pip介绍

pip最初旨在通过以下方式对easy_install进行改进

  • 所有软件包均在安装前已下载。结果不会发生部分完成的安装。
  • 注意在控制台上显示有用的输出。
  • 采取行动的原因已被跟踪。例如,如果正在安装软件包,则pip会跟踪为什么需要该软件包。
  • 错误消息应该很有用。
  • 该代码相对简洁明了,具有内聚性,可以更轻松地以编程方式使用。
  • 软件包不必作为Egg存档安装,可以将它们平放安装(同时保留Egg元数据)。
  • 对其他版本控制系统(Git,Mercurial和Bazaar)的本地支持
  • 卸载软件包。
  • 简单定义固定的需求集并可靠地复制一组包。

From Ian Bicking’s own introduction to pip:

pip was originally written to improve on easy_install in the following ways

  • All packages are downloaded before installation. Partially-completed installation doesn’t occur as a result.
  • Care is taken to present useful output on the console.
  • The reasons for actions are kept track of. For instance, if a package is being installed, pip keeps track of why that package was required.
  • Error messages should be useful.
  • The code is relatively concise and cohesive, making it easier to use programmatically.
  • Packages don’t have to be installed as egg archives, they can be installed flat (while keeping the egg metadata).
  • Native support for other version control systems (Git, Mercurial and Bazaar)
  • Uninstallation of packages.
  • Simple to define fixed sets of requirements and reliably reproduce a set of packages.

回答 2

另一个(至今尚未提及)之所以喜欢点子,是因为它是新的热点,并将在未来继续使用。

以下信息图表(来自《The Hitchhiker’s Guide to Packaging v1.0》中的包装当前状态”部分)表明setuptools / easy_install将来会消失。

在此处输入图片说明

这是Distribution的文档中的另一个信息图,显示Setuptools和easy_install将被新的热点— distributionpip取代。虽然PIP仍然是新的辣味,分发与合并的setuptools在2013年发布的setuptools V0.7。

在此处输入图片说明

Another—as of yet unmentioned—reason for favoring pip is because it is the new hotness and will continue to be used in the future.

The infographic below—from the Current State of Packaging section in the The Hitchhiker’s Guide to Packaging v1.0—shows that setuptools/easy_install will go away in the future.

enter image description here

Here’s another infographic from distribute’s documentation showing that Setuptools and easy_install will be replaced by the new hotness—distribute and pip. While pip is still the new hotness, Distribute merged with Setuptools in 2013 with the release of Setuptools v0.7.

enter image description here


回答 3

有两个原因,可能还有更多:

  1. pip提供uninstall命令

  2. 如果中间安装失败,则pip将使您保持干净状态。

Two reasons, there may be more:

  1. pip provides an uninstall command

  2. if an installation fails in the middle, pip will leave you in a clean state.


回答 4

需求文件。

认真地说,我每天都将它与virtualenv结合使用。


快速依赖管理教程,民谣

需求文件使您可以创建已通过pip安装的所有软件包的快照。通过将这些程序包封装在虚拟环境中,可以使代码库在一组非常特定的程序包中工作,并与其他人共享该代码库。

从Heroku的文档中 https://devcenter.heroku.com/articles/python

您创建一个虚拟环境,并设置您的外壳以使用它。(bash / * nix指令)

virtualenv env
source env/bin/activate

现在,与此外壳一起运行的所有python脚本都将使用该环境的软件包和配置。现在,您可以在此环境中本地安装软件包,而无需在计算机上全局安装。

pip install flask

现在,您可以转储有关安装哪些软件包的信息

pip freeze > requirements.txt

如果您将该文件签入版本控制中,那么当其他人获取您的代码时,他们可以设置自己的虚拟环境并使用以下命令安装所有依赖项:

pip install -r requirements.txt

任何时候您都可以像这样自动执行乏味的操作。

REQUIREMENTS files.

Seriously, I use this in conjunction with virtualenv every day.


QUICK DEPENDENCY MANAGEMENT TUTORIAL, FOLKS

Requirements files allow you to create a snapshot of all packages that have been installed through pip. By encapsulating those packages in a virtualenvironment, you can have your codebase work off a very specific set of packages and share that codebase with others.

From Heroku’s documentation https://devcenter.heroku.com/articles/python

You create a virtual environment, and set your shell to use it. (bash/*nix instructions)

virtualenv env
source env/bin/activate

Now all python scripts run with this shell will use this environment’s packages and configuration. Now you can install a package locally to this environment without needing to install it globally on your machine.

pip install flask

Now you can dump the info about which packages are installed with

pip freeze > requirements.txt

If you checked that file into version control, when someone else gets your code, they can setup their own virtual environment and install all the dependencies with:

pip install -r requirements.txt

Any time you can automate tedium like this is awesome.


回答 5

pip不会安装二进制软件包,并且未在Windows上经过良好测试。

由于Windows默认没有附带编译器,因此通常无法在其中使用pip 。easy_install 可以为Windows安装二进制软件包。

pip won’t install binary packages and isn’t well tested on Windows.

As Windows doesn’t come with a compiler by default pip often can’t be used there. easy_install can install binary packages for Windows.


回答 6

更新:正如某些人所想,setuptools已经吸收distribute了相反的东西。setuptools是最新的最新distutils更改和滚轮格式。因此,easy_installpip或多或少平等现在。

来源:http : //pythonhosted.org/setuptools/merge-faq.html#why-setuptools-and-not-distribute-or-another-name

UPDATE: setuptools has absorbed distribute as opposed to the other way around, as some thought. setuptools is up-to-date with the latest distutils changes and the wheel format. Hence, easy_install and pip are more or less on equal footing now.

Source: http://pythonhosted.org/setuptools/merge-faq.html#why-setuptools-and-not-distribute-or-another-name


回答 7

除了模糊人的答复:

pip不会安装二进制软件包,并且未在Windows上经过良好测试。

由于Windows默认不带编译器,因此通常无法在其中使用pip。easy_install可以为Windows安装二进制软件包。

这是Windows上的一个技巧:

  • 您可以使用easy_install <package>安装二进制软件包来避免生成二进制文件

  • pip uninstall <package>即使您使用过easy_install,也可以使用 。

这只是在Windows上对我有效的解决方法。实际上,如果不涉及二进制文件,我总是使用pip。

请参阅当前的pip doku:http://www.pip-installer.org/en/latest/other-tools.html#pip-compared-to-easy-install

我将在邮件列表中询问为此计划的内容。

这是最新的更新:

新的受支持的安装二进制文件的方式将是wheel!它尚未在标准中,但几乎已经存在。当前版本仍为Alpha:1.0.0a1

https://pypi.python.org/pypi/wheel

http://wheel.readthedocs.org/en/latest/

我将wheel通过创建要PySide使用的OS X安装程序进行测试wheel,而不是蛋。会回来并报告此情况。

欢呼声-克里斯

快速更新:

到的过渡wheel即将结束。大多数软件包都支持wheel

我答应为制作车轮PySide,去年夏天我做了。很棒!

提示:一些开发商至今未能支撑轮格式,仅仅是因为他们忘记更换distutilssetuptools。通常,通过替换中的单个单词很容易转换此类软件包setup.py

As an addition to fuzzyman’s reply:

pip won’t install binary packages and isn’t well tested on Windows.

As Windows doesn’t come with a compiler by default pip often can’t be used there. easy_install can install binary packages for Windows.

Here is a trick on Windows:

  • you can use easy_install <package> to install binary packages to avoid building a binary

  • you can use pip uninstall <package> even if you used easy_install.

This is just a work-around that works for me on windows. Actually I always use pip if no binaries are involved.

See the current pip doku: http://www.pip-installer.org/en/latest/other-tools.html#pip-compared-to-easy-install

I will ask on the mailing list what is planned for that.

Here is the latest update:

The new supported way to install binaries is going to be wheel! It is not yet in the standard, but almost. Current version is still an alpha: 1.0.0a1

https://pypi.python.org/pypi/wheel

http://wheel.readthedocs.org/en/latest/

I will test wheel by creating an OS X installer for PySide using wheel instead of eggs. Will get back and report about this.

cheers – Chris

A quick update:

The transition to wheel is almost over. Most packages are supporting wheel.

I promised to build wheels for PySide, and I did that last summer. Works great!

HINT: A few developers failed so far to support the wheel format, simply because they forget to replace distutils by setuptools. Often, it is easy to convert such packages by replacing this single word in setup.py.


回答 8

刚遇到一个我不得不easy_install代替的特殊情况pip,否则我必须直接提取源代码。

对于该软件包GitPython,in中的版本pip太旧,即0.1.7,而from中的版本easy_install是最新的,即0.3.2.rc1

我正在使用Python 2.7.8。我不知道有关的底层机制easy_installpip,但至少有一些包的版本可能是彼此不同的,有时easy_install是一个较新的版本。

easy_install GitPython

Just met one special case that I had to use easy_install instead of pip, or I have to pull the source codes directly.

For the package GitPython, the version in pip is too old, which is 0.1.7, while the one from easy_install is the latest which is 0.3.2.rc1.

I’m using Python 2.7.8. I’m not sure about the underlay mechanism of easy_install and pip, but at least the versions of some packages may be different from each other, and sometimes easy_install is the one with newer version.

easy_install GitPython

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。