一条推文写道:
不要使用easy_install,除非您
就像捅自己的脸一样。
使用脉冲。
为什么使用pip而不是easy_install?错误不主要在于PyPI和包作者吗?如果作者上传垃圾源tarball(例如:丢失文件,没有setup.py)到PyPI,那么pip和easy_install都将失败。除了外观上的差异之外,为什么Python使用者(就像上面的推文一样)似乎更喜欢pip而不是easy_install?
(让我们假设我们谈论的是来自分发包的easy_install,它由社区维护)
要求的文件。
说真的,我每天都将它与virtualenv结合使用。
快速依赖管理教程,伙计们
需求文件允许您创建通过pip安装的所有包的快照。通过在虚拟环境中封装这些包,你可以让你的代码库使用一组非常特定的包,并与其他人共享该代码库。
来自Heroku的文档https://devcenter.heroku.com/articles/python
您创建了一个虚拟环境,并设置shell来使用它。(bash / * nix指令)
virtualenv env
source env/bin/activate
现在所有使用该shell运行的python脚本都将使用该环境的包和配置。现在您可以在本地将包安装到此环境中,而不需要在您的机器上全局安装它。
pip install flask
现在您可以转储有关已安装的软件包的信息
pip freeze > requirements.txt
如果你将该文件签入版本控制,当其他人得到你的代码时,他们可以设置自己的虚拟环境并安装所有依赖项:
pip install -r requirements.txt
任何时候你都可以像这样自动化枯燥的工作,这真是太棒了。
作为对fuzzyman回复的补充:
pip不会安装二进制包,并且在Windows上没有经过很好的测试。
由于Windows默认情况下没有编译器,pip通常不能
使用。easy_install用于安装Windows的二进制包。
这里有一个关于Windows的技巧:
您可以使用easy_install <package>来安装二进制包,以避免生成二进制文件
即使使用easy_install,也可以使用PIP uninstall <package>。
这只是一个变通的工作,为我的窗户。
实际上,如果不涉及二进制文件,我总是使用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而不是eggs为PySide创建一个OS X安装程序来测试wheel。会回来报告这件事的。
干杯——克里斯
快速更新:
向车轮的过渡几乎结束了。大多数包都是支承轮。
我答应为PySide做轮子,去年夏天我就做了。工作好了!
提示:
到目前为止,一些开发人员未能支持轮式格式,只是因为他们忘记了
用setuptools替换distutils。
通常,通过替换setup.py中的这个单词就可以很容易地转换这样的包。
这里的许多答案在2015年已经过时了(尽管丹尼尔·罗斯曼最初接受的答案并没有过时)。以下是目前的情况:
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 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.