How to identify conda package dependents?

conda info will tell you the directory (or directories) where your package cache is located. These directories contain a unique directory for each package, and each package directory contains an info directory and a file called index.json. There is a requires field in each of these files that refers to a list of conda dependencies. So in short, you need to search these files for the package you're trying to remove.

For example, if anaconda's installed in my home directory, and therefore the package cache is ~/anaconda/pkgs, to find mpich2's dependents, I would:

grep mpich2 ~/anaconda/pkgs/*/info/index.json

You will see 2 lines for the anaconda package, because mpich2 is both in the aforementioned requires list and in a list called depends. You'll also see one line for each mpich2 package available, because there is also a name field for each package. Then you'll see one or more lines for each package that depends on, requires mpich2. My search produced only mpi4py.

Now I thought you could do a --dry-run remove, but it appears that remove does not remove dependents, so nothing special is listed.

If grep is unavailable, then I'm sure you could make a python script to do the same thing, using say the globmodule and maybe even json to do the searching.


With recent versions of conda, you can do

conda remove --dry-run <package>

to get a list of packages that would be uninstalled along with the given one.

Tags:

Conda