一、conda的作用
Conda是适用于任何语言的软件包、依赖项和环境管理系统--包括Python,R,Ruby,Lua,Scala,Java,JavaScript,C / C ++,FORTRAN等。
Conda是在Windows、macOS和Linux上运行的开源软件包管理系统和环境管理系统。Conda可以快速安装、运行和更新软件包及其依赖项。Conda可以轻松地在本地计算机上的环境中创建,保存,加载和切换。它是为Python程序创建的,但可以打包和分发适用于任何语言的软件。
Conda作为软件包管理器,可以帮助您查找和安装软件包。如果您需要一个能够使用不同版本Python的软件包,则无需切换到其他环境管理器,因为conda也是环境管理器。仅需几个命令,您就可以设置一个完全独立的环境来运行不同版本的Python,同时继续在正常环境中运行喜欢的Python版本。
在默认配置下,conda可以安装和管理来自repo.anaconda.com仓库的7,500多个软件包,该仓库由Anaconda生成,审查和维护。
Conda也可以与Travis CI和AppVeyor等持续集成系统结合使用,以提供对代码的频繁,自动化测试。
所有版本的Anaconda, Miniconda和 Anaconda存储库均包含conda软件包和环境管理器 。Conda也被包含在Anaconda Enterprise中,该公司为Python,R,Node.js,Java和其他应用程序堆栈提供现场企业包和环境管理。Conda还可以在社区频道conda- forge上获取 。当然,也可以在PyPI中获取Conda,但是通过这种方法可能不是最新的。
注:PyPI是Python编程语言的软件存储库,全称为“The Python Package Index”。通过PyPI也可以发现和安装由Python社区开发和共享的软件包。
总的来说,Conda是一个辅助进行包管理和环境管理的工具。目前是Ananconda默认的Python包和环境管理工具,所以安装了Ananconda完整版,就默认安装了Conda。Conda既具有pip的包管理能力,同时也具有vitualenv的环境管理功能 ,因此在功能上Conda可以看作是pip 和 vitualenv 的组合。
二、Conda与pip的区别
在python的包管理工具方面,为什么有了pip(对于python3,可能是pip3), 我们还需要conda?
下面仅给出几个stackoverflow上查到的解释和说明,供参考。
解释说明1
https://stackoverflow.com/questions/31899966/pip-install-vs-conda-install
Pip installs from PyPI. There are no releases of the basemap package on PyPI, it is just a simple registration page pointing at the real download location (SourceForge).
Conda pulls from its own repository, typically with convenience builds of libraries common to the community Conda is aimed at. Conda's repository has a version of the basemap package available for installation, so it succeeds.
This is not to say that Pip is "worse" than Conda in this instance, as you could easily download the package and install it with pip locally. This particular library has just opted to not add releases to PyPI.
大致翻译如下:
解释说明2
https://stackoverflow.com/questions/20994716/what-is-the-difference-between-pip-and-conda?rq=1
Quetion:
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
?
Answer1:
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.
大致翻译如下:
参与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上已经发布了新的页面(https://www.anaconda.com/understanding-conda-and-pip/),该页面上说道:
这凸显了conda和pip之间的关键区别。Pip安装Python软件包,而conda安装软件包,其中可能包含以任何语言编写的软件。例如,在使用pip之前,必须通过系统软件包管理器或下载并运行安装程序来安装Python解释器。另一方面,Conda可以直接安装Python软件包以及Python解释器。
并进一步
有时需要一个软件包,该软件包不是conda软件包,但在PyPI上可用,可以与pip一起安装。在这些情况下,尝试同时使用conda和pip是有意义的。
Answer 2:
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, butconda 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).
大致翻译如下:
pip
- 仅Python软件包。
- 从源代码编译所有内容。注意:pip现在会安装二进制wheels(如果可用)。
- 受核心Python社区的推荐(即Python 3.4+包含自动引导pip的代码)。
conda
- 不可知的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的原因。由于pip是从源代码安装的,因此如果您无法编译源代码,则可能会很麻烦地安装东西(在Windows上尤其如此,但在Linux上,如果软件包中包含一些困难的C或FORTRAN库,甚至可能也是这样。依赖项)。Conda从二进制安装,这意味着某人(例如Continuum)已经完成了编译软件包的艰苦工作,因此安装很容易。
如果您对构建自己的软件包感兴趣,也有一些区别。例如,pip是建立在setuptools之上的,而Conda使用它自己的格式,这种格式具有一些优势(例如,静态的,Python不可知的)。
Answer3:
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
从中使用。
参考链接:https://conda.io/projects/conda/en/latest/