8 Replies - 394 Views - Last Post: 05 March 2019 - 08:22 AM Rate Topic: -----

#1 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 363
  • Joined: 14-February 17

Problems with graphviz

Posted 27 February 2019 - 03:34 PM

Here is the code I'm using straight from the documentation:
from graphviz import Digraph
dot = Digraph(comment='The Round Table')
dot.node('A', 'King Arthur')
dot.node('B', 'Sir Bedevere the Wise')
dot.node('L', 'Sir Lancelot the Brave')
dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')
print(dot.source)
dot.render('test-output/round-table.gv', view=True)




In my IED editor everything appears fine, so I do not see what is going wrong. It prints the dot object, as follows:

// The Round Table
digraph {
A [label="King Arthur"]
B [label="Sir Bedevere the Wise"]
L [label="Sir Lancelot the Brave"]
A -> B
A -> L
B -> L [constraint=false]
}




But when I get to the last line of code, I get an error message.


Here is the error message I'm getting:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/graphviz/backend.py", line 111, in run
proc = subprocess.Popen(cmd, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in init
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'dot'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "use_graphiz.py", line 15, in 
dot.render('test-output/round-table.gv', view=True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/graphviz/files.py", line 176, in render
rendered = backend.render(self._engine, self._format, filepath)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/graphviz/backend.py", line 142, in render
run(cmd, capture_output=True, check=True, quiet=quiet)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/graphviz/backend.py", line 114, in run
raise ExecutableNotFound(cmd)
graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'test-output/round-table.gv'], make sure the Graphviz executables are on your systems' PATH



Is This A Good Question/Topic? 0
  • +

Replies To: Problems with graphviz

#2 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 363
  • Joined: 14-February 17

Re: Problems with graphviz

Posted 27 February 2019 - 03:50 PM

I think this is the part in the documentation that I need to understand, found here

https://graphviz.readthedocs.io/

Quote

After installing Graphviz, make sure that its bin/ subdirectory containing the layout commands for rendering graph descriptions (dot, circo, neato, etc.) is on your systems’ path: On the command-line, dot -V should print the version of your Graphiz installation.


As usual the software writers have no idea how to communicate. I don't know what they mean by 'on your systems path'.

if this is what they mean

str1 = "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/graphviz/"
sys.path.append(str1)


Then I've done that but that didn't help.

This post has been edited by bobsmith76: 27 February 2019 - 03:52 PM

Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6775
  • View blog
  • Posts: 27,938
  • Joined: 12-December 12

Re: Problems with graphviz

Posted 28 February 2019 - 12:25 AM

System paths refers to your system's environment variables for paths, which species where to look for applications and files. It enables running an application from any location.
Was This Post Helpful? 0
  • +
  • -

#4 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 363
  • Joined: 14-February 17

Re: Problems with graphviz

Posted 04 March 2019 - 01:23 AM

I've done some more research

When I run graphviz I get the following error

graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'test-output/aoc.gv.pdf'], make sure the Graphviz executables are on your systems' PATH

I don't know what the graphviz executables are. In any case, my best guess is that I have to add the path of the module that uses graphviz or I have to add the graphviz module to my .bash_profile. Currently, my bash_profile has this line:

PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}

So I tried adding the path of where the module that uses Graphviz is located which is

/Users/me/PycharmProjects/inference_engine2/inference2/proofs/other/use_graphviz.py

Plus the graphviz module itself which is:

/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/graphviz/

Making the final product to be:

PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}:/Users/me/PycharmProjects/inference_engine2/inference2/proofs/other/use_graphviz.py:/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/graphviz/"

But that did not work. I need to know what string I have to add to the PATH.
Was This Post Helpful? 0
  • +
  • -

#5 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 976
  • View blog
  • Posts: 3,849
  • Joined: 13-June 14

Re: Problems with graphviz

Posted 04 March 2019 - 02:01 AM

View Postbobsmith76, on 04 March 2019 - 08:23 AM, said:

I don't know what the graphviz executables are.


The program that you use to run Graphviz, not its Python modules. Do you have Graphviz installed? If not, then you need to install it and make sure the path to the executable is in $PATH.
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6775
  • View blog
  • Posts: 27,938
  • Joined: 12-December 12

Re: Problems with graphviz

Posted 04 March 2019 - 02:04 AM

I searched "make sure the Graphviz executables are on your systems" to find this which suggests, or confirms, that you are looking for dot.exe. Different suggestions are provided for Linux and Mac.
Was This Post Helpful? 0
  • +
  • -

#7 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 363
  • Joined: 14-February 17

Re: Problems with graphviz

Posted 04 March 2019 - 03:43 AM

View Postndc85430, on 04 March 2019 - 09:01 AM, said:

View Postbobsmith76, on 04 March 2019 - 08:23 AM, said:

I don't know what the graphviz executables are.


The program that you use to run Graphviz, not its Python modules. Do you have Graphviz installed?

yes.

Quote

If not, then you need to install it and make sure the path to the executable is in $PATH.

I know that this is what I have to do but I don't know what that means and consequently do not know how to do it. What is an executable? From my research I'm pretty sure that I need to alter this string in my .bash_profile as I stated in my OP

PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}:/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/graphviz/

Someone over at Github said: "the directory that need to be added to the PATH is the one that contains the binaries from Graphviz"

I don't which directory that is but I think it's the aforementioned:

/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/graphviz/

Since that has a dot.py file in it. So I tried:

PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}:/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/graphviz/dot.py

But that didn't work.

Also Andrew mentioned

https://stackoverflo...ystems-path-aft

I've seen that thread before but I did not see the part about conda. I downloaded Conda and ran

Conda install graphviz

And got:
ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.

But I can't pip install miniconda, so I just downloaded. After I downloaded it, my computer installed it but I could not find it in my applications.

Apparently there's also some way homebrew can help out. I have that installed but when I input

brew install graphviz

That doesn't help.

This post has been edited by bobsmith76: 04 March 2019 - 03:43 AM

Was This Post Helpful? 0
  • +
  • -

#8 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6775
  • View blog
  • Posts: 27,938
  • Joined: 12-December 12

Re: Problems with graphviz

Posted 04 March 2019 - 08:03 AM

Quote

What is an executable?

There are more technical descriptions, and disagreements about the term, but, essentially, it is not a data file and something that can be executed from the operating system directly, such as by double-clicking the file.

Typical extensions are .exe (and .com) and perhaps batch files could be considered executables. .exe for this purpose, but I don't know about Linux or Mac.
Was This Post Helpful? 0
  • +
  • -

#9 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 363
  • Joined: 14-February 17

Re: Problems with graphviz

Posted 05 March 2019 - 08:22 AM

Problem solved. It took me a while to figure out that I had to download some non-pythonic software before I could get the pythonic software to work.

brew install graphviz

Was step 1 and I had done that before but I was getting an error message. It told me to change ownership of some files so I did that. Then tried

brew install graphviz

again and that did the trick.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1