For a given conda
package, how to I list the packages that depend on it?
I recently installed anaconda on a university cluster that already had a version of MPI (openmpi). The mpich2
package and mpi4py
packages installed with anaconda were fine for demos of mpi4py, but the mpi*
compilers (mpicc, etc) were not compatable. So I conda remove
'd mpich2
and mpi4py
and used pip
to install mpi4py
using the local MPI install and compilers.
I had to dig around to find mpi4py
's dependencies and then mpich2
's dependents, for which I only identified mpi4py
. Is there an "easy" way to find out what depends on mpich2
?
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 glob
module and maybe even json
to do the searching.
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