Installing pygrahviz in google colab
Asked Answered
S

2

9

In order to install graphviz, one can follow, this example: https://colab.research.google.com/drive/1_Qb92Hj5_f2rpta67JC0JKXwE2581Ar-#scrollTo=BOa9gIcDo6GS

When I try to install pygraphviz (https://pygraphviz.github.io/) via (https://pypi.org/project/pygraphviz/)

with

!pip install pygraphviz
import pygraphviz as pgv

i get the error

ERROR: Failed building wheel for pygraphviz

although I installed graphviz before. Why?

Schweinfurt answered 24/10, 2019 at 6:45 Comment(0)
F
2

You don't need to pip install anything.

Just import graphviz, not pygraphviz.

My minimal example:

https://colab.to/1PVtFECaDgMfVjed4XNtvyeL4pyMvPdAT

Felid answered 24/10, 2019 at 9:14 Comment(2)
In graphviz, how do I read in a dot string like digraph{ # Graph style "ordering"="out" "rankdir"="TD" ######### # Nodes # ######### "Add(Symbol(x), Symbol(y))_()" ["color"="black", "label"="Add", "shape"="ellipse"]; "Symbol(x)_(0,)" ["color"="black", "label"="x", "shape"="ellipse"]; "Symbol(y)_(1,)" ["color"="black", "label"="y", "shape"="ellipse"]; ######### # Edges # ######### "Add(Symbol(x), Symbol(y))_()" -> "Symbol(x)_(0,)"; "Add(Symbol(x), Symbol(y))_()" -> "Symbol(y)_(1,)"; }Schweinfurt
See "custom dot statement", and "using raw dot" in the doc. graphviz.readthedocs.io/en/stable/manual.htmlFelid
H
26

Though the answer by @korakot solved the issue, but it does not address the issue of installing pygraphviz library in Google Colab.

If you have to do install pygraphviz in Google Colab then the following worked for me.

# graphviz is installed already, but need lib too
!apt install libgraphviz-dev
!pip install pygraphviz

I found this solution here: https://gist.github.com/korakot/a80c04a1945b06e2f4a053f92fecfbf9

Hideous answered 26/2, 2021 at 4:10 Comment(0)
F
2

You don't need to pip install anything.

Just import graphviz, not pygraphviz.

My minimal example:

https://colab.to/1PVtFECaDgMfVjed4XNtvyeL4pyMvPdAT

Felid answered 24/10, 2019 at 9:14 Comment(2)
In graphviz, how do I read in a dot string like digraph{ # Graph style "ordering"="out" "rankdir"="TD" ######### # Nodes # ######### "Add(Symbol(x), Symbol(y))_()" ["color"="black", "label"="Add", "shape"="ellipse"]; "Symbol(x)_(0,)" ["color"="black", "label"="x", "shape"="ellipse"]; "Symbol(y)_(1,)" ["color"="black", "label"="y", "shape"="ellipse"]; ######### # Edges # ######### "Add(Symbol(x), Symbol(y))_()" -> "Symbol(x)_(0,)"; "Add(Symbol(x), Symbol(y))_()" -> "Symbol(y)_(1,)"; }Schweinfurt
See "custom dot statement", and "using raw dot" in the doc. graphviz.readthedocs.io/en/stable/manual.htmlFelid

© 2022 - 2024 — McMap. All rights reserved.