为什么要在easy_install上使用pip? [英] Why use pip over easy_install?
问题描述
tweet 读为:
请勿使用easy_install,除非您 就像在脸上刺伤自己一样. 使用点子.
Don't use easy_install, unless you like stabbing yourself in the face. Use pip.
为什么在easy_install上使用pip? 故障不是PyPI造成的,而软件包作者大多是?如果作者将废话源tarball(例如:缺少文件,没有setup.py)上传到PyPI,则pip和easy_install都将失败.除了外观上的差异外,为什么Python的人(如上述推文中)似乎强烈更喜欢pip而非easy_install?
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?
(假设我们正在谈论由社区维护的Distribute软件包中的easy_install)
(Let's assume that we're talking about easy_install from the Distribute package, that is maintained by the community)
推荐答案
许多答案在2015年已过期(尽管最初被丹尼尔·罗斯曼(Daniel Roseman)接受的人不是).这是当前的状态:
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:
- 二进制软件包现在作为转轮分发(
.whl
文件)—不仅在PyPI上,而且在第三方存储库中,例如添加到2.6 +/3.1 +中)virtualenv
)已成为一个非常重要且引人注目的工具(在官方文档);它们开箱即用,包括pip
,但甚至不能与easy_install
一起正常使用. - 不再维护包含
easy_install
的distribute
程序包.它对setuptools
的改进已合并回setuptools
.尝试安装distribute
只会安装setuptools
. -
easy_install
本身仅是准维护的. -
pip
以前不如easy_install
的所有情况(从解压缩的源树安装,从DVCS仓库等安装)都已一去不复返了;您可以pip install .
,pip install git+https://
. -
pip
带有python.org的官方Python 2.7和3.4+软件包,如果从源代码构建,默认情况下会包含pip
引导程序. - Python打包用户指南取代了有关安装,使用和构建软件包的各种文档的不完整之处.一个>. 安装Python模块上Python自己的文档现在遵照此用户指南,并明确调用
pip
作为首选安装程序". - 多年来,
pip
中已添加了其他新功能,这些功能将永远不会出现在easy_install
中.例如,通过pip
可以轻松地克隆站点程序包,方法是构建需求文件,然后在每一侧使用单个命令进行安装.或将您的需求文件转换为本地回购以用于内部开发.依此类推.
- 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
virtualenv
) have become a very important and prominent tool (and recommended in the official docs); they includepip
out of the box, but don't even work properly witheasy_install
. - The
distribute
package that includedeasy_install
is no longer maintained. Its improvements oversetuptools
got merged back intosetuptools
. Trying to installdistribute
will just installsetuptools
instead. easy_install
itself is only quasi-maintained.- All of the cases where
pip
used to be inferior toeasy_install
—installing from an unpacked source tree, from a DVCS repo, etc.—are long-gone; you canpip install .
,pip install git+https://
. pip
comes with the official Python 2.7 and 3.4+ packages from python.org, and apip
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 ineasy_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.
我知道在2015年使用easy_install
的唯一很好的理由是在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
.
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.
这篇关于为什么要在easy_install上使用pip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!