我知道pip是python包的包管理器。但是,我在IPython的网站上看到了使用conda安装IPython的安装。
我可以用pip安装IPython吗?当我已经有pip时,为什么我要使用conda作为另一个python包管理器?
pip和conda的区别是什么?
我知道pip是python包的包管理器。但是,我在IPython的网站上看到了使用conda安装IPython的安装。
我可以用pip安装IPython吗?当我已经有pip时,为什么我要使用conda作为另一个python包管理器?
pip和conda的区别是什么?
当前回答
引用Conda: Myths and misconcepts(一个全面的描述):
...
误解3:Conda和pip是直接竞争对手
事实:Conda和pip服务于不同的目的,并且只在一小部分任务上直接竞争:即在孤立的环境中安装Python包。
Pip是Pip安装包的缩写,是Python官方认可的包管理器,最常用于安装发布在Python包索引(PyPI)上的包。pip和PyPI都由Python打包管理局(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和pip不是竞争对手,而是专注于不同用户组和使用模式的工具。
其他回答
PIP是一个包管理器。
Conda既是包管理器,也是环境管理器。
细节:
依赖项检查
Pip and conda also differ in how dependency relationships within an environment are fulfilled. When installing packages, pip installs dependencies in a recursive, serial loop. No effort is made to ensure that the dependencies of all packages are fulfilled simultaneously. This can lead to environments that are broken in subtle ways, if packages installed earlier in the order have incompatible dependency versions relative to packages installed later in the order. In contrast, conda uses a satisfiability (SAT) solver to verify that all requirements of all packages installed in an environment are met. This check can take extra time but helps prevent the creation of broken environments. As long as package metadata about dependencies is correct, conda will predictably produce working environments.
参考文献
理解康达和皮普
引用Conda博客:
由于在python世界中工作了很长时间,我们都知道pip、easy_install和virtualenv,但是这些工具并不能满足我们所有的特定需求。主要的问题是它们关注Python,忽略了非Python库的依赖关系,如HDF5、MKL、LLVM等,这些库的源代码中没有setup.py,也没有将文件安装到Python的site-packages目录中。
因此,Conda是一个打包工具和安装程序,它的目标是比pip做的更多;处理Python包之外的库依赖项以及Python包本身。Conda还创建了一个虚拟环境,就像virtualenv一样。
因此,也许可以将Conda与Buildout进行比较,后者是另一个可以同时处理Python和非Python安装任务的工具。
因为Conda引入了一种新的打包格式,所以pip和Conda不能互换使用;pip无法安装Conda包格式。您可以同时使用这两个工具(通过使用conda install pip安装pip),但它们也不能互操作。
在写下这个答案后,Anaconda发表了一个关于理解Conda和Pip的新页面,这也与此相呼应:
这突出了conda和pip之间的一个关键区别。Pip安装Python包,而conda安装的包可能包含用任何语言编写的软件。例如,在使用pip之前,必须通过系统包管理器或下载并运行安装程序来安装Python解释器。另一方面,Conda可以直接安装Python包以及Python解释器。
再进一步
有时需要一个包,这个包不能作为conda包使用,但可以在PyPI上使用,并且可以用pip安装。在这些情况下,尝试同时使用conda和pip是有意义的。
免责声明:这个答案描述的是十年前的情况,当时pip还不支持二进制包。Conda是专门为更好地支持构建和分发二进制包而创建的,特别是带有C扩展的数据科学库。作为参考,pip只获得了带轮子的便携式二进制包的广泛支持(2013年的pip 1.4)和manylinux1规范(2016年3月的pip 8.1)。查看最近的答案了解更多历史。
以下是一个简短的概述:
pip
只支持Python包。 从源代码编译所有内容。编辑:pip现在安装二进制车轮,如果他们是可用的。 受到核心Python社区的支持(即Python 3.4+包含自动引导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 an environment and package manager. It is included in the Anaconda Python distribution provided by Continuum Analytics (now called Anaconda, Inc.).
conda is an environment manager written in Python and is language-agnostic. conda environment management functions cover the functionality provided by venv, virtualenv, pipenv, pyenv, and other Python-specific package managers. You could use conda within an existing Python installation by pip installing it (though this is not recommended unless you have a good reason to use an existing installation). As of 2022, conda and pip are not fully aware of one another package management activities within a virtual environment, not are they interoperable for Python package management.
在这两种情况下:
用Python编写 开源(conda是BSD, pip是MIT) 警告:虽然conda本身是开源的,但包存储库由Anaconda Inc托管,并且在商业使用方面有限制。
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.
如果您对构建自己的包感兴趣,也有一些不同之处。例如,pip构建在setuptools之上,而conda使用自己的格式,这有一些优点(比如是静态的,并且与Python无关)。
WINDOWS用户
“标准”包装工具的情况最近有所改善:
截至2015年9月11日,pypi本身的车轮包装数量为48%(2015年5月为38%,2014年9月为24%), 最新的python 2.7.9版本现在支持开箱即用的wheel格式,
“标准”+“微调”包装工具的情况也在改善:
你可以在http://www.lfd.uci.edu/~gohlke/pythonlibs上找到几乎所有的科学软件包, mingwpy项目可能有一天会给Windows用户带来一个“编译”包,允许他们在需要的时候从源代码安装所有东西。
“Conda”包装对于它所服务的市场来说仍然更好,并强调了“标准”应该改进的地方。
(此外,在标准wheel系统和conda系统或buildout中的依赖规范multiple-effort不是很python化,如果所有这些打包“核心”技术可以通过某种PEP聚合在一起就好了)
引用Conda: Myths and misconcepts(一个全面的描述):
...
误解3:Conda和pip是直接竞争对手
事实:Conda和pip服务于不同的目的,并且只在一小部分任务上直接竞争:即在孤立的环境中安装Python包。
Pip是Pip安装包的缩写,是Python官方认可的包管理器,最常用于安装发布在Python包索引(PyPI)上的包。pip和PyPI都由Python打包管理局(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和pip不是竞争对手,而是专注于不同用户组和使用模式的工具。