Skip to content

Instantly share code, notes, and snippets.

@gabrielcnr
Forked from ericdill/render_env.py
Created September 16, 2019 21:20
Show Gist options
  • Select an option

  • Save gabrielcnr/ad5da0d04b0bf755b2253cedc1e90a15 to your computer and use it in GitHub Desktop.

Select an option

Save gabrielcnr/ad5da0d04b0bf755b2253cedc1e90a15 to your computer and use it in GitHub Desktop.
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))
dg.node(j['name'])
for dep in j.get('depends', []):
dg.edge(j['name'], dep.split(' ')[0])
dg.render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment