Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Render the dependency graph for your conda environment (needs graphviz!)
import json
import glob
from os.path import join, basename
# install this with "conda install -c conda-forge python-graphviz"
import graphviz as gv
# path to your conda environment
path = '/tmp/foo'
dg = gv.Digraph(filename='env-%s' % basename(path), format='svg')
for json_file in glob.glob(join(path, 'conda-meta', '*.json')):
print('reading', json_file)
j = json.load(open(json_file))
for dep in j.get('depends', []):
dg.edge(j['name'], dep.split(' ')[0])

This comment has been minimized.

Copy link

@msarahan msarahan commented Apr 6, 2018

expanded example that uses repodata.json instead of json in packages:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment