# Subgraph Python setup

**URL:** https://forum.graphviz.org/t/subgraph-python-setup/1061
**Category:** Help
**Created:** [March 8, 2022, 4:29pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061 "2022-03-08T16:29:43Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pluro](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pluro](https://forum.graphviz.org/u/pluro)
#### Post date: [March 8, 2022, 4:29pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061/1 "2022-03-08T16:29:43Z")

</div>

Hi Graphviz,  
I am working to setup the digraph and subgraph example found here

> **[Cluster Gradients](https://graphviz.org/Gallery/gradient/cluster.html)**
>
> Demonstrates the use of cluster gradients.

I have pip installed graphviz and am trying to get this code to run locally in a python script. I am getting an invalid syntax error on the digraph name ‘G’. Are there any additional installs or requirements that are not specified in this example that I sent in the link?

---

<div class="post-metadata">

### Author: ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)
#### Post date: [March 8, 2022, 6:48pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061/2 "2022-03-08T18:48:01Z")

</div>

(Note: I am not a Python user or a pip user. The following is based on lots of Stackoverflow comments)  
I don’t believe that pip really installs Graphviz. I believe pip only installs an _interface_ to Graphviz. To check, go to a command line/terminal and type `dot -V`.  
To install Graphviz, go here: [Download | Graphviz](https://graphviz.org/download/)

---

<div class="post-metadata">

### Author: ![pluro](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pluro](https://forum.graphviz.org/u/pluro)
#### Post date: [March 8, 2022, 7:11pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061/3 "2022-03-08T19:11:58Z")

</div>

Thank you for the reply! I actually have tried ‘brew install Graphviz’ and I am also getting a similar error in how digraph initialization is not getting recognized by my python file. I am using Pycharm as an editor. I looking at the Python interpreter, I see that the Graphviz package version 0.19.1 is installed. I get an invalid syntax error on the digraph declaratoion. Is this version not correct?

---

<div class="post-metadata">

### Author: ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)
#### Post date: [March 8, 2022, 7:22pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061/4 "2022-03-08T19:22:01Z")

</div>

That is not a Graphviz version. Graphviz versions run from (approximately) 2.43 to (approximately) 3.0. I believe you are seeing the version number of the Python-to-Graphviz interface.  
Read this [graphviz · PyPI](https://pypi.org/project/graphviz/) and note the text that says:

> To render the generated DOT source code, you also need to install [Graphviz](https://www.graphviz.org) ([download page](https://www.graphviz.org/download/), [archived versions](https://www2.graphviz.org/Archive/stable/), [installation procedure for Windows](https://forum.graphviz.org/t/new-simplified-installation-procedure-on-windows/224)).

I wish they would rename their interface and/or improve their documentation.

---

<div class="post-metadata">

### Author: ![pluro](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pluro](https://forum.graphviz.org/u/pluro)
#### Post date: [March 8, 2022, 7:22pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061/5 "2022-03-08T19:22:55Z")

</div>

Thank you for the reply! I actually have tried ‘brew install Graphviz’ and I am also getting a similar error in how digraph initialization is not getting recognized by my python file.

dot -v on the terminal returns:  
dot - graphviz version 2.50.0 (20211204.2007)

Also, in my Pycharm editor interpreter window I see graphviz with a version of 0.19.1

Are there any other dependencies that I am not considering?

---

<div class="post-metadata">

### Author: ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)
#### Post date: [March 8, 2022, 10:39pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061/6 "2022-03-08T22:39:02Z")

</div>

Best guess: you probably have everything you need installed. Maybe there really is (just) a syntax error. If so, is it a Python syntax error or a Graphviz syntax error?

On this page ([graphviz · PyPI](https://pypi.org/project/graphviz/)) note the part that says

> check the generated source code

I’d do that and then run that “manually” thru **dot**

---

<div class="post-metadata">

### Author: ![pluro](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pluro](https://forum.graphviz.org/u/pluro)
#### Post date: [March 9, 2022, 3:21pm UTC](https://forum.graphviz.org/t/subgraph-python-setup/1061/8 "2022-03-09T15:21:09Z")

</div>

thank you! I am able to get the diagram to generate by running the script as a dot file and running the scripts using dot
