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

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

pip和conda的区别是什么?


当前回答

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仅用于Python

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

引用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环境中使用PIP,它会验证上面的一般管理器注释和特定于python的管理器注释。

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

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

我可以用pip安装iPython吗?

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

pip install ipython

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

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

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

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

正如这里所说:

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

Conda在(YMMV)中超过pip

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

pip和conda的区别是什么?

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

免责声明:这个答案描述的是十年前的情况,当时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无关)。