问题:pip和conda有什么区别?

我知道pip是python软件包的软件包管理器。但是,我看到IPython网站conda上的安装用于安装IPython。

我可以pip用来安装IPython吗?conda我已经拥有了为什么还要用作另一个python软件包管理器pip

pip和之间有什么区别conda

I know pip is a package manager for python packages. However, I saw the installation on IPython’s website use conda to install IPython.

Can I use pip to install IPython? Why should I use conda as another python package manager when I already have pip?

What is the difference between pip and conda?


回答 0

引用来自Conda博客

参与python世界已经很长时间了,我们都知道pip,easy_install和virtualenv,但是这些工具不能满足我们所有的特定要求。主要问题是它们专注于Python,而忽略了非Python库依赖项,例如HDF5,MKL,LLVM等,它们的源代码中没有setup.py,也没有将文件安装到Python的站点中-packages目录。

因此,Conda是一种包装工具和安装程序,旨在做更多的事情pip。处理Python包之外的库依赖关系以及Python包本身。Conda也像创建虚拟环境一样virtualenv

因此,也许应该将Conda与Buildout进行比较,后者是另一个可以让您处理Python和非Python安装任务的工具。

由于Conda引入了新的包装格式,因此您不能pip与Conda互换使用。 pip无法安装Conda软件包格式。您可以使用并排的两个工具侧(通过安装pipconda install pip),但他们不具备互操作性无论是。

自编写此答案以来,Anaconda 理解Conda和Pip发布了新页面,该页面也与此相呼应:

这凸显了conda和pip之间的关键区别。Pip安装Python软件包,而conda安装软件包,其中可能包含以任何语言编写的软件。例如,在使用pip之前,必须通过系统软件包管理器或下载并运行安装程序来安装Python解释器。另一方面,Conda可以直接安装Python软件包以及Python解释器。

并进一步

有时需要一个软件包,该软件包不是conda软件包,但在PyPI上可用,可以与pip一起安装。在这些情况下,尝试同时使用conda和pip是有意义的。

Quoting from the Conda blog:

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. 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.

So Conda is a packaging tool and installer that aims to do more than what pip does; handle library dependencies outside of the Python packages as well as the Python packages themselves. Conda also creates a virtual environment, like virtualenv does.

As such, Conda should be compared to Buildout perhaps, another tool that lets you handle both Python and non-Python installation tasks.

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side (by installing pip with conda install pip) but they do not interoperate either.

Since writing this answer, Anaconda has published a new page on Understanding Conda and Pip, which echoes this as well:

This highlights a key difference between conda and pip. Pip installs Python packages whereas conda installs packages which may contain software written in any language. For example, before using pip, a Python interpreter must be installed via a system package manager or by downloading and running an installer. Conda on the other hand can install Python packages as well as the Python interpreter directly.

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. In these cases, it makes sense to try to use both conda and pip.


回答 1

这是一个简短的摘要:

点子

  • 仅Python软件包。
  • 从源代码编译所有内容。编辑:pip现在会安装二进制车轮(如果可用)。
  • 受核心Python社区的祝福(即Python 3.4+包含自动引导pip的代码)。

康达

  • 不可知的Python。现有软件包的主要焦点是用于Python,的确Conda本身是用Python编写的,但是您也可以拥有用于C库,R软件包或其他任何东西的Conda软件包。
  • 安装二进制文件。有一个名为的工具conda build可以从源代码构建软件包,但conda install它本身可以从已构建的Conda软件包安装东西。
  • 外部。Conda是Anaconda的软件包管理器,它是Continuum Analytics提供的Python发行版,但也可以在Anaconda之外使用。您可以通过pip安装将其与现有的Python安装配合使用(尽管除非您有充分的理由使用现有的安装,否则不建议这样做)。

在两种情况下:

  • 用Python编写
  • 开源(Conda是BSD,pip是MIT)

实际上,Conda的前两个要点是使许多包装优于点子的原因。由于pip是从源代码安装的,因此如果您无法编译源代码,则可能会很麻烦地安装东西(在Windows上尤其如此,但在Linux上,如果软件包中包含一些困难的C或FORTRAN库,甚至可能也是这样。依赖项)。Conda从二进制安装,这意味着某人(例如Continuum)已经完成了编译软件包的艰苦工作,因此安装很容易。

如果您对构建自己的软件包感兴趣,也有一些区别。例如,pip是建立在setuptools之上的,而Conda使用自己的格式,这种格式具有一些优点(例如,静态的,Python不可知的)。

Here is a short rundown:

pip

  • Python packages only.
  • Compiles everything from source. EDIT: pip now installs binary wheels, if they are available.
  • Blessed by the core Python community (i.e., Python 3.4+ includes code that automatically bootstraps pip).

conda

  • Python agnostic. 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.
  • 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.
  • External. Conda is the package manager of Anaconda, the Python distribution provided by Continuum Analytics, but it can be used outside of Anaconda too. 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).

In both cases:

  • Written in Python
  • Open source (Conda is BSD and pip is MIT)

The first two bullet points of Conda are really what make it advantageous over pip for many packages. 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). Conda installs from binary, meaning that someone (e.g., Continuum) has already done the hard work of compiling the package, and so the installation is easy.

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).


回答 2

其他答案对这些细节给出了合理的描述,但我想强调一些高级要点。

pip是一个软件包管理器,可简化python软件包的安装,升级和卸载。它还适用于虚拟python环境。

conda是任何软件(安装,升级和卸载)的软件包管理器。它还适用于虚拟系统环境。

conda设计的目标之一是促进用户所需的整个软件堆栈的软件包管理,其中一个或多个python版本可能只是其中的一小部分。这包括低级库(例如线性代数),编译器(例如Windows上的mingw),编辑器,版本控制工具(例如Hg和Git)或其他需要分发和管理的内容

对于版本管理,pip允许您在多个python环境之间切换和管理。

Conda允许您在多个通用环境之间进行切换和管理,在多个通用环境中,其他多个版本的版本号可能会有所不同,例如C库,编译器,测试套件或数据库引擎等。

Conda不是以Windows为中心的,但是在Windows上,当需要安装和管理需要编译的复杂科学软件包时,它是目前可用的高级解决方案。

当我想到尝试通过Windows上的pip编译许多这些软件包或pip install在需要编译时调试失败的会话时浪费了多少时间时,我想哭。

最后,Continuum Analytics还托管(免费)binstar.org(现在称为anaconda.org),以允许常规软件包开发人员创建自己的自定义(内置!)软件堆栈,包用户可以conda install从中使用它们。

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. It also works with virtual python environments.

conda is a package manager for any software (installation, upgrade and uninstallation). 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. 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.

For version management, pip allows you to switch between and manage multiple python environments.

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 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.

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.

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.


回答 3

不要再让您感到困惑了,但是您也可以在conda环境中使用pip,这可以验证上面的一般管理员和python特定管理员的评论。

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

您还可以将pip添加到任何环境的默认程序包中,因此每次都会显示pip,因此您不必遵循上述代码段。

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 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.


回答 4

引用康达在Continuum网站上发表的关于数据科学的文章:

康达vs点

Python程序员可能很熟悉pip从PyPI下载软件包并管理他们的要求。尽管conda和pip都是程序包管理器,但它们却大不相同:

  • Pip是特定于Python软件包的,而conda是与语言无关的,这意味着我们可以使用conda管理任何语言的软件包。
  • Conda本机创建与语言无关的环境,而pip依靠virtualenv仅管理Python环境尽管建议始终使用conda软件包,但conda也包含pip,因此您不必在这两者之间进行选择。例如,要安装没有conda软件包但可通过pip获得的python软件包,请运行,例如:
conda install pip
pip install gensim

Quote from Conda for Data Science article onto Continuum’s website:

Conda vs pip

Python programmers are probably familiar with pip to download packages from PyPI and manage their requirements. Although, both conda and pip are package managers, they are very different:

  • Pip is specific for Python packages and conda is language-agnostic, which means we can use conda to manage packages from any language Pip compiles from source and conda installs binaries, removing the burden of compilation
  • Conda creates language-agnostic environments natively whereas pip relies on virtualenv to manage only Python environments Though it is recommended to always use conda packages, conda also includes pip, so you don’t have to choose between the two. For example, to install a python package that does not have a conda package, but is available through pip, just run, for example:
conda install pip
pip install gensim

回答 5

引用《Conda:神话与误解》(全面描述):

误解3:Conda和Pip是直接竞争对手

现实:Conda和pip服务于不同的目的,仅直接竞争一小部分任务:即在隔离的环境中安装Python软件包。

皮普,代表P IP nstalls P ackages,是Python的官方认可的包管理器,并且是最常用的在其上安装Python包索引(PyPI中)发布的数据包。pip和PyPI均受Python Packaging Authority(PyPA)管辖和支持。

简而言之,pip是Python软件包的通用管理器。conda是与语言无关的跨平台环境管理器。对于用户而言,最明显的区别可能是:pip在任何环境中安装python软件包;conda在conda环境中安装任何软件包。如果您要做的只是在隔离的环境中安装Python软件包,则conda和pip + virtualenv通常是可互换的,从而在依赖项处理和软件包可用性方面取得了一些差异。隔离环境是指conda-env或virtualenv,您可以在其中安装软件包而无需修改系统Python安装。

即使抛开神话#2,如果我们只关注Python软件包的安装,conda和pip也可以为不同的受众和不同的目的服务。例如,如果要管理现有系统Python安装中的Python软件包,conda不能为您提供帮助:根据设计,它只能在conda环境中安装软件包。例如,如果您想使用许多依赖于外部依赖关系的Python包(NumPy,SciPy和Matplotlib是常见的示例),而以有意义的方式跟踪这些依赖关系时,pip并不能帮助您:通过设计,它仅管理Python软件包。

Conda和pip不是竞争对手,而是针对不同用户群和使用方式的工具。

Quoting from Conda: Myths and Misconceptions (a comprehensive description):

Myth #3: Conda and pip are direct competitors

Reality: Conda and pip serve different purposes, and only directly compete in a small subset of tasks: namely installing Python packages in isolated environments.

Pip, which stands for Pip Installs Packages, is Python’s officially-sanctioned package manager, and is most commonly used to install packages published on the Python Package Index (PyPI). Both pip and PyPI are governed and supported by the Python Packaging Authority (PyPA).

In short, pip is a general-purpose manager for Python packages; conda is a language-agnostic cross-platform environment manager. For the user, the most salient distinction is probably this: pip installs python packages within any environment; conda installs any package within conda environments. If all you are doing is installing Python packages within an isolated environment, conda and pip+virtualenv are mostly interchangeable, modulo some difference in dependency handling and package availability. By isolated environment I mean a conda-env or virtualenv, in which you can install packages without modifying your system Python installation.

Even setting aside Myth #2, if we focus on just installation of Python packages, conda and pip serve different audiences and different purposes. If you want to, say, manage Python packages within an existing system Python installation, conda can’t help you: by design, it can only install packages within conda environments. If you want to, say, work with the many Python packages which rely on external dependencies (NumPy, SciPy, and Matplotlib are common examples), while tracking those dependencies in a meaningful way, pip can’t help you: by design, it manages Python packages and only Python packages.

Conda and pip are not competitors, but rather tools focused on different groups of users and patterns of use.


回答 6

对于WINDOWS用户

最近,“标准”包装工具的状况正在改善:

  • 截至9月,在pypi本身上,有48%的车轮包装。2015年11月11日(高于2015年5月的38%和2014年9月的24%),

  • 现在,最新的python 2.7.9支持开箱即用的wheel格式,

“标准” +“调整”包装工具的状况也在改善:

  • 您可以在http://www.lfd.uci.edu/~gohlke/pythonlibs上找到几乎所有关于转轮格式的科学软件包,

  • mingwpy项目可能有一天为Windows用户带来一个“编译”包,允许在需要时从源代码安装所有内容。

“康达”包装对于所服务的市场而言仍然更好,并强调了“标准” 应该改进的地方。

(同样,在标准车轮系统和conda系统中,或者在扩展方面,依赖规范的多方面努力不是很Python,如果所有这些打包的“核心”技术都可以通过某种PEP收敛,那就太好了)

For WINDOWS users

“standard” packaging tools situation is improving recently:

  • on pypi itself, there are now 48% of wheel packages as of sept. 11th 2015 (up from 38% in may 2015 , 24% in sept. 2014),

  • the wheel format is now supported out-of-the-box per latest 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,

  • the mingwpy project may bring one day a ‘compilation’ package to windows users, allowing to install everything from source when needed.

“Conda” packaging remains better for the market it serves, and highlights areas where the “standard” should improve.

(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)


回答 7

pip 是包裹经理。

conda 既是包管理器又是环境管理器。

详情:

在此处输入图片说明

参考文献

pip is a package manager.

conda is both a package manager and an environment manager.

Detail:

enter image description here

References


回答 8

我可以使用pip安装iPython吗?

当然,两者(第一种方法在页面上)

pip install ipython

和(第三种方法,第二种是conda

您可以从GitHub或PyPI手动下载IPython。要安装这些版本之一,请解压缩它并使用终端从顶级源目录运行以下命令:

pip install .

官方推荐的安装方法

当我已经有了pip时,为什么还要使用conda作为另一个python软件包管理器?

这里所说:

如果您需要一个特定的软件包,也许仅用于一个项目,或者需要与其他人共享该项目,那么conda似乎更合适。

康达(YMMV)超过点

  • 使用非Python工具的项目
  • 与同事分享
  • 在版本之间切换
  • 在具有不同库版本的项目之间切换

pip和conda有什么区别?

其他所有人对此都有广泛的回答。

Can I use pip to install iPython?

Sure, both (first approach on page)

pip install ipython

and (third approach, second is conda)

You can manually download IPython from GitHub or PyPI. To install one of these versions, unpack it and run the following from the top-level source directory using the Terminal:

pip install .

are officially recommended ways to install.

Why should I use conda as another python package manager when I already have pip?

As said here:

If you need a specific package, maybe only for one project, or if you need to share the project with someone else, conda seems more appropriate.

Conda surpasses pip in (YMMV)

  • projects that use non-python tools
  • sharing with colleagues
  • switching between versions
  • switching between projects with different library versions

What is the difference between pip and conda?

That is extensively answered by everyone else.


回答 9

pip 仅适用于Python

conda仅适用于Anaconda +其他科学软件包,例如R依赖等。并非每个人都需要Python附带的Anaconda。Anaconda主要适合那些进行机器学习/深度学习等的人。Casual Python开发人员不会在他的笔记本电脑上运行Anaconda。

pip is for Python only

conda is only for Anaconda + other scientific packages like R dependencies etc. NOT everyone needs Anaconda that already comes with Python. Anaconda is mostly for those who do Machine learning/deep learning etc. Casual Python dev won’t run Anaconda on his laptop.


回答 10

我可能已经发现了另一小的区别。我在python环境下/usr而不是在/home任何环境下。为了安装它,我将不得不使用sudo install pip。对我来说,不想要的副作用sudo install pip是比被广泛报道的其他地方略有不同:这样做之后,我还得跑pythonsudo以进口任何的sudo-installed包。我放弃了这一点,最终发现我可以sudo conda将软件包安装到一个环境中/usr,然后在该环境下可以正常导入而不需要sudo获得许可python。我什sudo conda至习惯于修复损坏的东西,pip而不是使用sudo pip uninstall pipor sudo pip --upgrade install pip

I may have found one further difference of a minor nature. I have my python environments under /usr rather than /home or whatever. In order to install to it, I would have to use sudo install pip. For me, the undesired side effect of sudo install pip was slightly different than what are widely reported elsewhere: after doing so, I had to run python with sudo in order to import any of the sudo-installed packages. I gave up on that and eventually found I could use sudo conda to install packages to an environment under /usr which then imported normally without needing sudo permission for python. I even used sudo conda to fix a broken pip rather than using sudo pip uninstall pip or sudo pip --upgrade install pip.


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