Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specific reasons to favor pip vs. conda when installing Python packages

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

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.

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


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?"

like image 947
Dustin Michels Avatar asked Feb 22 '19 20:02

Dustin Michels


People also ask

Should I install packages with pip or conda?

It's fully recommended to use pip inside of conda. It's better to install using conda, but for any packages that don't have a conda build, it's perfectly acceptable to use pip.

What is the difference between using pip install and conda install?

The fundamental difference between pip and Conda packaging is what they put in packages. Pip packages are Python libraries like NumPy or matplotlib . Conda packages include Python libraries (NumPy or matplotlib ), C libraries ( libjpeg ), and executables (like C compilers, and even the Python interpreter itself).

Why you should use Python pip?

pip is a recommended tool for installing Python packages. For example, if you need to install an external package/library, say requests, you have to install it first using pip. In your current scenario, you may not have to use external libraries.

Should I use pip conda?

Rather than running conda, pip and then conda again, a more reliable method is to create a new environment with the combined conda requirements and then run pip. According to the Anaconda for Practitioners Guide, many users rely on simply the “root” conda environment that is created by installing Anaconda (“base”).


1 Answers

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

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.

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 and pip are not competitors, but rather tools focused on different groups of users and patterns of use.

like image 163
eatmeimadanish Avatar answered Sep 21 '22 04:09

eatmeimadanish