Since conda install
and pip install
in many cases do essentially the same thing, what would be the best option? Is there a case when someone should stick to pip install
only? Symmetrical, is there a case when one should stick to conda install
only? Is there a way to shoot in one's foot by using both conda and pip install in a single environment?
If both approaches are essentially the same and don't contradict each other there should be no reason to stick solely to one of them but not to the other.
According to the Anaconda for Practitioners Guide, many users rely on simply the “root” conda environment that is created by installing Anaconda (“base”). If this environment becomes cluttered with a mix of pip and conda installs, it is much harder to recover and you may lose valuable work.
You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment. If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.
Also as rightly pointed out pip installs from PyPi and conda gets packages from its own anaconda repo. pip on the other hand has advantages, that it can install packages that conda doesn't have and also it supports system wide installs for packages.
conda install installs any package in conda environments An example would be the tensorflow library, pip requires CUDA and other software requirements to be preinstalled, but conda installs all necessary and compatible dependencies automatically. Also as rightly pointed out pip installs from PyPi and conda gets packages from its own anaconda repo.
Since I am using Spider, I should use "conda install". But some packages can not be installed in "conda install" while they easily can be installed in "pip install". For example, I installed Keras in "pip install" but in Spider, Keras can not be imported (Keras is not known). Then, I again installed Keras in conda install form.
Running conda after pip has the potential to overwrite and potentially break packages installed via pip. Similarly, pip may upgrade or remove a package which a conda-installed package requires.
Don't mix conda install
and pip install
within conda environment. Probably, decide to use conda
or virtualenv+pip
once and for all. And here is how you decide which one suits you best:
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 for 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 the latest version of Python some of the packages would only be available through pip. And the 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's advantages).
Conda is the best when it comes to managing dependencies and replicating environments. When uninstalling a 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 the new machine is not too different, replicate that environment somewhere else. Also, conda can have 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:
Some outdated notions:
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: Using Pip in a Conda Environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With