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

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

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

其他回答

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聚合在一起就好了)

我可以用pip安装iPython吗?

当然,两者都有(第一个方法)

pip install ipython

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

您可以从GitHub或PyPI手动下载IPython。安装一个 对于这些版本,解压它并从顶层运行以下命令 源目录使用终端: PIP安装。

都是官方推荐的安装方式。

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

正如这里所说:

如果您需要一个特定的包(可能只用于一个项目),或者需要与其他人共享该项目,那么conda似乎更合适。

Conda在(YMMV)中超过pip

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

pip和conda的区别是什么?

每个人都广泛地回答了这个问题。

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.

参考文献

理解康达和皮普

要回答最初的问题, 对于安装包,PIP和Conda是完成相同任务的不同方式。两者都是安装包的标准应用程序。主要的区别是包文件的来源。

PIP/PyPI将有更多的“实验性”包,或者更新的、不太常见的包版本 Conda通常会有更完善的包或版本

一个重要的警告提示:如果使用两个源(pip和conda)在同一环境中安装包,以后可能会导致问题。

重建环境将更加困难 修复包不兼容性变得更加复杂

最佳实践是选择一个应用程序(PIP或Conda)来安装包,并使用该应用程序安装所需的任何包。 然而,仍然有许多例外或理由在conda环境中使用pip,反之亦然。 例如:

如果您需要的包只存在于一个包上,则 其他人没有。 您需要一个只在一个环境中可用的特定版本

引用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不是竞争对手,而是专注于不同用户组和使用模式的工具。