1

I'm trying to use the pydot.Dot.write_png(...) with pydot and it fails to locate graphviz. I've tried countless number of approaches/fixes to this problem, but they all seem to be for older versions of pydot and graphviz and are not working in my case. I'm running a windows 10 and here are the approaches i tried -


Approach 1) Setting the path in the systems environment variables and then restarting system/pycharm. Screenshot -enter image description here

PS- I've added these to both, system variables and user variables. Also, the graphiz version is a bit older in the screenshot because I also tried uninstalling the latest graphviz and then installing this version because people seemed to have got it working in this version.

Approach 2) I have installed graphviz via the msi from their website, and also through pip install graphviz. Also done installing graphviz first and then pydot (If the order even mattered as some solutions suggested). Even tried doing it with pydotplus.

Approach 3) Solutions seemed to hint at tinkering with pydot.find_graphviz in the pydot.py. However this function is not present in pydot versions above 1.1.0 (2016). And i think the latest versions of python do not support the installation of this pydot version.

Approach 4) I ran command prompt as admin and then did dot -c and dot -v as one solution suggested. Honestly, I don't even know what this did. Some promising stuff but still didn't fix it.

I'd greatly appreciate some insights on this. Thank you!

Nikz
  • 71
  • 6
  • Great first question, very glad to see that you've did some research already! Can you perhaps post what error you're getting from `pydot.Dot.write_png`? – Saaru Lindestøkke Aug 13 '20 at 19:55
  • 1
    The [source code](https://github.com/pydot/pydot/blob/master/pydot.py#L1783) of this particular `pydot` function also states that you can specify the `dot` program location. Perhaps you can use something like `pydot.Dot.write_png(path='.\output\image.png', prog='C:\Program Files (x86)\Graphviz2.38\bin\dot')`? – Saaru Lindestøkke Aug 13 '20 at 20:04
  • Hi! It turned out to be oddly system-specific and worked on a different laptop by simply setting the path. Like you suggested, I used something like `graph.write_png('static/uploads/graph1.png')` and got the results. Still have no clue why it isn't working on my first system but I was running out of time and options. Thanks for your reply! – Nikz Aug 15 '20 at 12:15
  • But did you try setting the `prog` option on your first system? – Saaru Lindestøkke Aug 15 '20 at 12:18
  • Hi, I did not. It does look promising though. Sadly, I can't even test it anymore and get back to you cause the original laptops gone :)) – Nikz Aug 15 '20 at 12:29

1 Answers1

0

This has turned out to be oddly system-specific. I got it working on a different laptop by simply setting the path.

For those who can't get them working -

  1. Setting the proper path should get it working, even with the latest versions of graphviz and pydot (Graphviz 2.44.1 as of now). If not, try one of my 4 listed methods and the method written by Saaru in the comments and pray it works.

  2. Re-check your code and the write_png function and ignore the Pycharm reference/highlight for write_png The errors thrown are similar in nature (assertion error/etc), so it's easy to confuse them and attribute it to Graphviz not working/write_png, while in reality, it could be some minor error in your code.

Nikz
  • 71
  • 6