pip和conda有什么区别?

本文翻译自:What is the difference between pip and conda?

I know pip is a package manager for python packages. 我知道pip是python包的包管理器。 However, I saw the installation on IPython's website use conda to install IPython. 但是,我看到IPython网站上的安装使用conda来安装IPython。

Can I use pip to install IPython? 我可以使用pip来安装IPython吗? Why should I use conda as another python package manager when I already have pip ? 当我已经拥有pip时,为什么我应该使用conda作为另一个python包管理器?

What is the difference between pip and conda ? pipconda什么区别?


#1楼

参考:https://stackoom.com/question/1Q5gS/pip和conda有什么区别


#2楼

Quoting from the Conda blog : 引自Conda博客

Having been involved in the python world for so long, we are all aware of pip, easy_install, and virtualenv, but these tools did not meet all of our specific requirements. 我们长期参与python世界,我们都知道pip,easy_install和virtualenv,但这些工具并不能满足我们所有的特定要求。 The main problem is that they are focused around Python, neglecting non-Python library dependencies, such as HDF5, MKL, LLVM, etc., which do not have a setup.py in their source code and also do not install files into Python's site-packages directory. 主要问题是它们专注于Python,忽略了非Python库依赖项,如HDF5,MKL,LLVM等,它们的源代码中没有setup.py,也没有将文件安装到Python的站点中-packages目录。

So Conda is a packaging tool and installer that aims to do more than what pip does; 所以Conda是一个打包工具和安装程序,旨在做的不仅仅是pip做的事情; handle library dependencies outside of the Python packages as well as the Python packages themselves. 处理Python包之外的库依赖项以及Python包本身。 Conda also creates a virtual environment, like virtualenv does. Conda还创建了一个虚拟环境,就像virtualenv一样。

As such, Conda should be compared to Buildout perhaps, another tool that lets you handle both Python and non-Python installation tasks. 因此,Conda应该与Buildout进行比较, 是另一个可以让你处理Python和非Python安装任务的工具。

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; 因为Conda引入了新的包装格式,所以不能互换使用pip和Conda; pip cannot install the Conda package format. pip无法安装Conda包格式。 You can use the two tools side by side (by installing pip with conda install pip ) but they do not interoperate either. 您可以使用并排的两个工具侧(通过安装pipconda install pip ),但他们不具备互操作性无论是。

Since writing this answer, Anaconda has published a new page on Understanding Conda and Pip , which echoes this as well: 自写这个答案以来,Anaconda已经发布了一个关于理解Conda和Pip新页面 ,这也与此相呼应:

This highlights a key difference between conda and pip. 这凸显了conda和pip之间的关键区别。 Pip installs Python packages whereas conda installs packages which may contain software written in any language. Pip安装Python包,而conda安装包可能包含用任何语言编写的软件的包。 For example, before using pip, a Python interpreter must be installed via a system package manager or by downloading and running an installer. 例如,在使用pip之前,必须通过系统包管理器或下载并运行安装程序来安装Python解释器。 Conda on the other hand can install Python packages as well as the Python interpreter directly. 另一方面,Conda可以直接安装Python包以及Python解释器。

and further on 并进一步

Occasionally a package is needed which is not available as a conda package but is available on PyPI and can be installed with pip. 偶尔需要一个包,它不能用作conda包,但可以在PyPI上使用,可以用pip安装。 In these cases, it makes sense to try to use both conda and pip. 在这些情况下,尝试同时使用conda和pip是有意义的。


#3楼

Here is a short rundown: 这是一个简短的纲要:

pip 果仁

  • Python packages only. 仅限Python包。
  • Compiles everything from source. 从源代码编译所有内容。 EDIT: pip now installs binary wheels, if they are available. 编辑:pip现在安装二进制轮子,如果它们可用。
  • Blessed by the core Python community (ie, Python 3.4+ includes code that automatically boostraps pip). 由核心Python社区祝福(即Python 3.4+包括自动提升pip的代码)。

conda 康达

  • Python agnostic. Python不可知论者。 The main focus of existing packages are for Python, and indeed conda itself is written in Python, but you can also have conda packages for C libraries, or R packages, or really anything. 现有软件包的主要关注点是Python,实际上conda本身是用Python编写的,但你也可以为C库或R软件包或任何东西提供conda软件包。
  • Installs binaries. 安装二进制文件。 There is a tool called conda build that builds packages from source, but conda install itself installs things from already built conda packages. 有一个名为conda build的工具可以从源代码构建软件包,但是conda install本身可以安装已经构建的conda软件包。
  • External. 外部。 Conda is the package manager of Anaconda, the Python distribution provided by Continuum Analytics, but it can be used outside of Anaconda too. Conda是Anaconda的包管理器,它是由Continuum Analytics提供的Python发行版,但它也可以在Anaconda之外使用。 You can use it with an existing Python installation by pip installing it (though this is not recommended unless you have a good reason to use an existing installation). 您可以通过pip安装将它与现有的Python安装一起使用(尽管除非您有充分的理由使用现有安装,否则不建议这样做)。

In both cases: 在这两种情况下:

  • Written in Python 用Python编写
  • Open source (conda is BSD and pip is MIT) 开源(conda是BSD,pip是麻省理工学院)

The first two bullet points of conda are really what make it advantageous over pip for many packages. conda的前两个要点实际上是什么使它比许多包装的pip更有利。 Since pip installs from source, it can be painful to install things with it if you are unable to compile the source code (this is especially true on Windows, but it can even be true on Linux if the packages have some difficult C or FORTRAN library dependencies). 由于pip是从源代码安装的,如果你无法编译源代码,安装它就会很痛苦(在Windows上尤其如此,但如果软件包有一些困难的C或FORTRAN库,它甚至可以在Linux上运行依赖)。 Conda installs from binary, meaning that someone (eg, Continuum) has already done the hard work of compiling the package, and so the installation is easy. Conda从二进制安装,意味着有人(例如,Continuum)已经完成了编译包的艰苦工作,因此安装很容易。

There are also some differences if you are interested in building your own packages. 如果您有兴趣构建自己的包,也会有一些差异。 For instance, pip is built on top of setuptools, whereas conda uses its own format, which has some advantages (like being static, and again, Python agnostic). 例如,pip建立在setuptools之上,而conda使用自己的格式,这有一些优点(比如静态,再次,Python不可知)。


#4楼

The other answers give a fair description of the details, but I want to highlight some high-level points. 其他答案给出了详细的详细描述,但我想强调一些高级别的要点。

pip is a package manager that facilitates installation, upgrade, and uninstallation of python packages . pip是一个包管理器,便于安装,升级和卸载python包 It also works with virtual python environments. 它也适用于虚拟python环境。

conda is a package manager for any software (installation, upgrade and uninstallation). conda是任何软件 (安装,升级和卸载)的软件包管理器。 It also works with virtual system environments. 它也适用于虚拟系统环境。

One of the goals with the design of conda is to facilitate package management for the entire software stack required by users, of which one or more python versions may only be a small part. conda设计的目标之一是促进用户所需的整个软件堆栈的包管理,其中一个或多个python版本可能只是一小部分。 This includes low-level libraries, such as linear algebra, compilers, such as mingw on Windows, editors, version control tools like Hg and Git, or whatever else requires distribution and management . 这包括低级库,如线性代数,编译器,如Windows上的mingw,编辑器,Hg和Git等版本控制工具,或其他需要分发和管理的工具

For version management, pip allows you to switch between and manage multiple python environments. 对于版本管理,pip允许您在多个python环境之间切换和管理。

Conda allows you to switch between and manage multiple general purpose environments across which multiple other things can vary in version number, like C-libraries, or compilers, or test-suites, or database engines and so on. Conda允许您在多个通用环境之间切换和管理,其中多个其他内容可能因版本号而异,例如C库,编译器,测试套件或数据库引擎等。

Conda is not Windows-centric, but on Windows it is by far the superior solution currently available when complex scientific packages requiring compilation are required to be installed and managed. Conda不是以Windows为中心的,但在Windows上,当需要安装和管理需要编译的复杂科学包时,它是目前可用的优秀解决方案。

I want to weep when I think of how much time I have lost trying to compile many of these packages via pip on Windows, or debug failed pip install sessions when compilation was required. 当我想到在Windows上通过pip编译许多这些软件包失去了多少时间,或者在需要编译时调试失败的pip install会话时,我想要哭泣。

As a final point, Continuum Analytics also hosts (free) binstar.org (now called anaconda.org ) to allow regular package developers to create their own custom (built!) software stacks that their package-users will be able to conda install from. 最后一点,Continuum Analytics还托管(免费) binstar.org (现在称为anaconda.org ),允许常规软件包开发人员创建自己的自定义(内置!)软件堆栈,其软件包用户将能够从中进行conda install 。 。


#5楼

Not to confuse you further, but you can also use pip within your conda environment, which validates the general vs. python specific managers comments above. 不要混淆你,但你也可以在你的conda环境中使用pip,它可以验证上面的一般与python特定的管理者评论。

conda install -n testenv pip
source activate testenv
pip <pip command>

you can also add pip to default packages of any environment so it is present each time so you don't have to follow the above snippet. 您还可以将pip添加到任何环境的默认包中,以便每次都存在,这样您就不必遵循上面的代码段。


#6楼

For WINDOWS users 对于WINDOWS用户

"standard" packaging tools situation is improving recently: “标准”包装工具的情况最近有所改善:

  • on pypi itself, there are now 48% of wheel packages as of sept. 在pypi本身,截至9月,现在有48%的车轮包装。 11th 2015 (up from 38% in may 2015 , 24% in sept. 2014), 2015年11月(2015年5月为38%,2014年9月为24%),

  • the wheel format is now supported out-of-the-box per latest python 2.7.9, 现在支持每个最新的python 2.7.9开箱即用的轮式格式,

"standard"+"tweaks" packaging tools situation is improving also: “标准”+“调整”包装工具的情况也在改善:

  • you can find nearly all scientific packages on wheel format at http://www.lfd.uci.edu/~gohlke/pythonlibs , 你可以在http://www.lfd.uci.edu/~gohlke/pythonlibs找到几乎所有轮式的科学包装,

  • the mingwpy project may bring one day a 'compilation' package to windows users, allowing to install everything from source when needed. mingwpy项目可能会为Windows用户带来一天的“编译”包,允许在需要时从源安装所有内容。

"Conda" packaging remains better for the market it serves, and highlights areas where the "standard" should improve. “Conda”包装对其所服务的市场仍然更好,并突出了“标准” 应该改进的领域。

(also, the dependency specification multiple-effort, in standard wheel system and in conda system, or buildout, is not very pythonic, it would be nice if all these packaging 'core' techniques could converge, via a sort of PEP) (此外,依赖规范多次努力,在标准轮系统和conda系统或buildout中,并不是非常pythonic,如果所有这些包装'核心'技术可以通过某种PEP汇聚,那将是很好的)

发布了0 篇原创文章 · 获赞 52 · 访问量 35万+

猜你喜欢

转载自blog.csdn.net/CHCH998/article/details/105610634
今日推荐