Is that a bad idea to use conda and pip install on the same environment?

后端 未结 2 1405
南方客
南方客 2020-12-28 15:53

I am curious here.

Since conda install and pip install in many cases doing essentially the same thing, what would be the best option? Is there a case when someone s

相关标签:
2条回答
  • 2020-12-28 16:43

    Don't mix conda install and pip install within conda environment. Probably, decide to use conda or virtualenv+piponce and for all. And here is how you decide which one suits you best:

    • Conda installs various (not only python) conda-adopted packages within conda environment. It gets your environments right if you are into environments.
    • Pip installs python packages within python environment (virtualenv is one of them). It gets your python packages installed right.

    Safe way to use conda: don't rush for the latest stuff and stick to the available packages and you'll be fine.

    Safe way to use pip+virtualenv: if you see a dependency issue or wish to remove and clean up after package - don't. Just burn the house, abandon your old environment and create a new one. One command line and 2-5 minutes later things gonna be nice and tidy again.

    Pip is the best tool installing python packages among the two of them. Since pip packages normally come out first and only later are adopted for conda (by conda staff or contributors). Chances are, after updating or installing latest version of python some of the packages would only be available through pip. And latest freshest versions of packages would only be available in pip. And mixing pip and conda packages together can be a nightmare (at least if you want to utilize conda advantages).

    Conda is the best when it comes to managing dependencies and replicating environments. When uninstalling package conda can properly clean up after itself and has better control over conflicting dependency versions. Also, conda can export environment config and, if the planets are right at the moment and new machine is not too different, replicate that environment somewhere else. Also, conda can has larger control over the environment and can, for example, have a different version of python installed inside of it (virtualenv - only the python available in the system). You can always create a conda package when you have no freedom of choosing what to use.

    Some relevant facts:

    • Conda takes more space and time to setup
    • Conda might be better if you don't have admin rights on the system
    • Conda will help when you have no system python
    • virtualenv+pip will free you up of knowing lots of details like that

    Some outdated notions:

    • Conda used to be better for novice developers back in the days (2012ish). There is no usability gap anymore
    • Conda was linked to Continuum Analytics too much. Now Conda itself is opensource, the packages - not so much.
    0 讨论(0)
  • 2020-12-28 16:43

    Depends on the complexity of your environment really. Using pip for a few simple packages should not generate any issues. Using more pip installs raises the question "Why not use a pip venv then?"

    If you're not doing anything major, you might be able to have a mix of pip and conda installs

    There is an extensive explanation why mixing them can be a bad idea here https://www.anaconda.com/using-pip-in-a-conda-environment/

    0 讨论(0)
提交回复
热议问题