Install https://github.com/jrfonseca/gprof2dot
$ python -m cProfile -o profiler.pstats ./some/python/code.py
$ gprof2dot -f pstats profiler.pstats | dot -Tpng -o profiler.png # generate PNG calltree image
$ pyprof2calltree -i profiler.pstats -k # debug with kcachegrind