Trying to figure out where the packages are located

I am trying to figure out where the packages installed through conda are located. It causes all sort of confusion.
I can once you have non-base environment, pip packages are in $user/$env/lib.
which I Can conveniently see by "pip3 show -f | grep location: " to get ground truth path for pip packages.

But conda install packages are far more confusing and complicaed, I see once instaleld through "conda install <pgk_name> it is added to $user/pkgs directory.
but removing through "conda remove <pkg_name> does not necessarily make it go away.

So I kinda learned that the pkgs directory serves as some kind of cache by inspecting output:
conda info | grep cache, which I can clear by “conda clean” command. Which left me wondering still where the path where conda install package are located at.

How exactly are you hoping to use this information? As you noted, the packages are in the conda_root/pkgs directory. They are then normally hardlinked into the separate environment directories under conda_root/envs/env_name, typically under lib/pythonX.Y (as with a normal Python install). This means that all environments that use a particular package (including the same version) effectively re-use the same files, saving disk space. So the package files will appear to be “in” multiple places at once.

Using conda remove just unlinks the package from the environment from which you’re removing it. The package remains under conda_root/pkgs so that if you install it later into another environment, it can re-use that version. You can use conda clean to clean up packages that aren’t used in any environments.

Hopefully that helps, but like I say, what information will be helpful to you may depend on what you’re hoping to do with it.

2 Likes