Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

same package installed by both pip and conda

What happens if the same package is installed by both pip and conda in the same environment? Is conda designed to cope with this? Can you safely pip uninstall the pip version without messing up the conda version?

like image 887
Daniel Mahler Avatar asked Sep 27 '17 21:09

Daniel Mahler


2 Answers

They will be installed in the same directory such as /home/user/miniconda/env/envname/lib/python3.6/site-packages/requests.

So if you install a package by both conda and pip, then uninstall it by pip, the source code has gone. And that means you cannot use this package any more.

When installing packages, pip will check dist-info or egg-info directory while conda will check conda-meta directory. In this case, you can install the same package both by conda and pip if you install it by pip first and then install it by conda. In the reverse case, pip will consider that package has been already installed.

To completely uninstall a package installed both by conda and pip, you need to run both conda remove to remove information in conda-meta and pip uninstall to remove dist-info directory.

like image 129
Sraw Avatar answered Nov 02 '22 05:11

Sraw


According to this post on the Anaconda website, it depends on the package installed.

Issues can arise when conda and pip are used together to create an environment, especially when the tools are used back-to-back multiple times, establishing a state that can be hard to reproduce. Most of these issues stem from that fact that conda, like other package managers, has limited abilities to control packages it did not install. 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. In some cases these breakages are cosmetic, where a few files are present that should have been removed, but in other cases the environment may evolve into an unusable state.

You can remove the package installed as shown in the first answer. But an environment can be restored to a previous revision, in order to undo the damages done, if there are any, by using conda and pip together.

To list the history of each change to the current environment, use conda list --revisions And to restore it to the previous version, use conda install --revision 2, where 2 is a selected revision number.

like image 36
Msgun Avatar answered Nov 02 '22 05:11

Msgun