Sunday, October 11, 2020

pip vs. conda

 pip installs python packages in any environment.

conda installs any package in conda environments.


If you already have a Python installation that you're using, then the choice of which to use is easy:


If you installed Python using Anaconda or Miniconda, then use conda to install Python packages. If conda tells you the package you want doesn't exist, then use pip (or try conda-forge, which has more packages available than the default conda channel).


If you installed Python any other way (from source, using pyenv, virtualenv, etc.), then use pip to install Python packages


Finally, because it often comes up, I should mention that you should never use sudo pip install.


NEVER.


It will always lead to problems in the long term, even if it seems to solve them in the short-term. For example, if pip install gives you a permission error, it likely means you're trying to install/update packages in a system python, such as /usr/bin/python. Doing this can have bad consequences, as often the operating system itself depends on particular versions of packages within that Python installation. For day-to-day Python usage, you should isolate your packages from the system Python, using either virtual environments or Anaconda/Miniconda — I personally prefer conda for this, but I know many colleagues who prefer virtualenv.


references:

https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/

No comments:

Post a Comment