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

我可以用pip安装IPython吗?当我已经有pip时,为什么我要使用conda作为另一个python包管理器?

pip和conda的区别是什么?


当前回答

引用Conda for Data Science在Continuum网站上的文章:

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

其他回答

引用Conda for Data Science在Continuum网站上的文章:

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

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

PIP是一个包管理器,可以方便地安装、升级和卸载python包。它也适用于虚拟python环境。

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

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

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

Conda允许您在多个通用环境之间切换和管理,在这些环境中,许多其他东西的版本号可能不同,比如c库、编译器、测试套件或数据库引擎等等。

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

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

最后一点,Continuum Analytics还提供(免费的)binstar.org(现在叫anaconda.org),允许常规的软件包开发人员创建他们自己的自定义(构建的!)软件堆栈,他们的软件包用户可以从中安装conda。

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.

为了不让你们更困惑, 但是你也可以在conda环境中使用PIP,它会验证上面的一般管理器注释和特定于python的管理器注释。

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

您还可以将PIP添加到任何环境的默认包中,以便每次都显示它,这样您就不必遵循上面的代码段。

pip仅用于Python

conda只适用于Anaconda +其他科学包,如R依赖等。并不是每个人都需要蟒蛇,因为它已经和Python一起出现了。Anaconda主要是为那些做机器学习/深度学习等的人准备的。普通的Python开发人员不会在他的笔记本电脑上运行Anaconda。