The difference between conda install and pip install

Table of contents

foreword

1. Different scope

2. Different conditions of use

3. Different management capabilities for virtual environments

4. The number of available packages is different


foreword

        conda and pip are generally considered to be nearly identical, but although these two tools have some overlap in functionality, they are designed for different purposes.


1. Different scope

Anaconda is a cross-platform package and environment manager. It is not limited to Python, but may also include libraries and packages in languages ​​such as C and C++. It can be understood as "conda installs packages, and pip is only responsible for installing Python packages".

2. Different conditions of use

Before using pip, the Python interpreter must be installed in advance, while conda can directly install the Python package and the Python interpreter.

3. Different management capabilities for virtual environments

conda makes it easy to create and manage virtual environments that can contain different versions of Python and/or packages installed in them. This is useful when working with data science tools, as different tools may contain conflicting requirements, which may prevent them all from being installed into a single environment.

Pip has no built-in support for environments, but relies on other tools like virtualenv or venv to create isolated environments.

Pip and conda also differ in how they implement dependencies in the environment. When installing packages, pip installs dependencies in a recursive serial loop. No effort is made to ensure that all package dependencies are satisfied at the same time. If packages installed earlier in the sequence have incompatible versions of dependencies relative to packages installed later in the sequence, this can cause the environment to become corrupted in subtle ways. Instead, conda uses a Satisfaction (SAT) solver to verify that all requirements of all packages installed in the environment are met. This check might take extra time, but it helps prevent the creation of a broken environment. As long as the package metadata about dependencies is correct, conda produces working environments in a predictable manner.

4. The number of available packages is different

In actual use, conda and pip are often used together. One of the main reasons for combining pip with conda is that many times the packages that need to be installed can only be installed via pip. Over 1500 packages are available in the Anaconda repository, including the most popular data science, machine learning, and AI frameworks. These, and thousands of other packages available on the Anaconda cloud, can be installed using conda. Despite so many packages, it's still small compared to the over 150,000 packages available on PyPI. Sometimes a package is required which is not available as a conda package but is available on PyPI and can be installed using pip. In these cases, it makes sense to try using both conda and pip.

Refer to the official documentation:

Official views on pip and conda

Tags: The difference between conda install and pip install

python machine learning deep learning

Related: The difference between conda install and pip install