安装Python软件包时偏爱pip与conda的特定原因 [英] Specific reasons to favor pip vs. conda when installing Python packages

查看:108
本文介绍了安装Python软件包时偏爱pip与conda的特定原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用miniconda作为我的默认python安装.当前(2019年)关于何时使用conda vs. pip安装某些东西的看法是什么?

I use miniconda as my default python installation. What is the current (2019) wisdom regarding when to install something with conda vs. pip?

我通常的行为是使用pip安装所有内容,并且仅在无法通过pip获得软件包或pip版本无法正常工作时才使用conda.

My usual behavior is to install everything with pip, and only using conda if a package is not available through pip or the pip version doesn't work correctly.

始终偏爱conda install有优势吗?混合使用两个安装程序是否存在问题?我应该考虑哪些因素?

Are there advantages to always favoring conda install? Are there issues associated with mixing the two installers? What factors should I be considering?

目标:这不是基于意见的问题!我的问题是,当我可以选择使用pipconda安装python软件包时,如何做出明智的决定?不是告诉我哪个更好",而是"为什么,我会在另一个上使用一个,并且会回荡&;会导致问题/效率低下吗?"

OBJECTIVITY: This is not an opinion-based question! My question is when I have the option to install a python package with pip or conda, how do I make an informed decision? Not "tell me which is better, but "Why would I use one over the other, and will oscillating back & forth cause problems / inefficiencies?"

推荐答案

我发现我之所以首先使用conda仅仅是因为它安装了二进制文件,而不是如果没有该软件包,请尝试使用pip.例如,psycopg2在conda中的安装要比pip容易得多.

I find I use conda first simply because it installs the binary, than try pip if the package isn't there. For instance psycopg2 is far easier to install in conda than pip.

https://jakevdp.github.io /blog/2016/08/25/conda-myths-and-misconceptions/

Pip代表Pip Installs软件包,是Python官方认可的软件包管理器,最常用于安装在Python软件包索引(PyPI)上发布的软件包. pip和PyPI均受Python Packaging Authority(PyPA)的管辖和支持.

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

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

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.

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

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不是竞争对手,而是针对不同用户群和使用方式的工具.

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

这篇关于安装Python软件包时偏爱pip与conda的特定原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆