question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add option to pass explicitly path to GraphViz executable (useful in Windows 7)

See original GitHub issue

I am running Windows 7 64-bit. I installed graphviz-2.36.msi from http://www.graphviz.org/Download_windows.php but I install most programs to c:\app rather than c:\Program Files, and I get this message (see below). One problem is that there is no SOFTWARE\ATT registry key anymore. (perhaps related to https://code.google.com/p/pydot/issues/detail?id=65)

I think the bigger problem is that this discovery mechanism is a cat-and-mouse game with whatever the graphviz folks do.

===> Could you please add a function so that end-users can just set the graphviz path manually through whatever mechanism they see fit?

For now I’m just monkeypatching the pydot module:

def force_find_graphviz(graphviz_root):
   binpath = os.path.join(graphviz_root, 'bin')
   programs = 'dot twopi neato circo fdp sfdp'
   def helper():
     for prg in programs.split():
       if os.path.exists(os.path.join(binpath, prg)):
         yield ((prg, os.path.join(binpath, prg)))
       elif os.path.exists(os.path.join(binpath, prg+'.exe')):
         yield ((prg, os.path.join(binpath, prg+'.exe')))
   progdict = dict(helper())
   return lambda: progdict

pydot.find_graphviz = force_find_graphviz('c:/app/util/graphviz/2.36')



C:\tmp\blockdiag>python
Python 2.7.5 |Anaconda 1.9.1 (64-bit)| (default, May 31 2013, 10:45:37) [MSC v.1
500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydot
Couldn't import dot_parser, loading of dot files will not be possible.
>>> graph = pydot.Dot(graph_type='graph')
>>> graph.write_png('test.png')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\app\python\anaconda\1.6.0\lib\site-packages\pydot.py", line 1602, in
<lambda>
    lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))

  File "c:\app\python\anaconda\1.6.0\lib\site-packages\pydot.py", line 1696, in
write
    dot_fd.write(self.create(prog, format))
  File "c:\app\python\anaconda\1.6.0\lib\site-packages\pydot.py", line 1724, in
create
    self.progs = find_graphviz()
  File "c:\app\python\anaconda\1.6.0\lib\site-packages\pydot.py", line 409, in f
ind_graphviz
    "SOFTWARE\ATT\Graphviz", 0, win32con.KEY_QUERY_VALUE )
pywintypes.error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified
.')
>>>

Original issue reported on code.google.com by jmsa...@gmail.com on 28 Mar 2014 at 7:30

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
GoogleCodeExportercommented, May 27, 2016

Hello,

I have windows 7 32 bit and python 2.7

Here how I installed pydot for python

first I installed GraphViz using this link: http://www.graphviz.org/content/how-install-graphviz-windows-7-i-cant-find-set-file after that I installed Pyparsing then pydot (from this answer http://stackoverflow.com/questions/15951748/pydot-and-graphviz-error-couldnt-import-dot-parser-loading-of-dot-files-will)

pip install -Iv https://pypi.python.org/packages/source/p/pyparsing/pyparsing-1.5.7.tar.gz#md5=9be0fcdcc595199c646ab317c1d9a709
pip install pydot

After that when I tried this line of code:

graph.write_png('test.png')

I had a similar error:

File "c:\app\python\anaconda\1.6.0\lib\site-packages\pydot.py", line 409, in find_graphviz
    "SOFTWARE\ATT\Graphviz", 0, win32con.KEY_QUERY_VALUE )
pywintypes.error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.')

I solved this problem by changing the function find_graphviz() in the pydot.py file, here is the code that I used:

def find_graphviz():
    if os.sys.platform == 'win32':


        if os.environ.has_key('PROGRAMFILES'):
            #Change to your path
            path =  "C:\Program Files\Graphviz2.30\\bin"


        else:

            #Just in case, try the default...
            path = r"C:\Program Files\Graphviz2.30\bin"

        progs = __find_executables(path)

        if progs is not None :

            #print "Used default install location"

            return progs


       return None

Hope it helps. Cheers

Original comment by sara.ela...@gmail.com on 9 Feb 2015 at 5:29

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make sure the Graphviz executables are on your system's ...
I tried to put "C:\Python34\bin\dot.exe" in system's path, but it didn't work, and I even created a new environment variable "GRAPHVIZ_DOT" with value...
Read more >
Add folder to PATH ('GraphViz's executables not found' Fixed)
Python for Machine Learning | Install Graphviz | Install Pydotplus to visualize Decision Tree · What is the PATH on the command line,...
Read more >
Attributes - Graphviz
Instructions to customise the layout of Graphviz nodes, edges, graphs, subgraphs, and clusters. The table below describes the attributes used by ...
Read more >
gcc(1) - Linux manual page - man7.org
Most of the command-line options that you can use with GCC are useful for C programs; ... The usual way to run GCC...
Read more >
PyGraphviz Documentation
Historically, installing Graphviz and PyGraphviz on Windows has been ... *nix systems, the preferred way to do this is by setting the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found