2

I followed graph-tool installation instructions in the the following link(https://colab.research.google.com/github/count0/colab-gt/blob/master/colab-gt.ipynb#scrollTo=d_j7nNbKRmhx). However, it throws the following error


<ipython-input-3-3f634eeb007c> in <module>()
----> 1 state.draw()

/usr/lib/python3/dist-packages/graph_tool/inference/nested_blockmodel.py in draw(self, **kwargs)
    986         draws the hierarchical state."""
    987         import graph_tool.draw
--> 988         return graph_tool.draw.draw_hierarchy(self, **kwargs)
    989 
    990 

AttributeError: module 'graph_tool.draw' has no attribute 'draw_hierarchy' ```
user206089
  • 21
  • 2
  • That function won't be available if there's a problem with the `cairo` dependency. ([See here.](https://git.skewed.de/count0/graph-tool/-/blob/9f620ac19e71cbddaacad3eb2b3eb0c80cce644c/src/graph_tool/draw/__init__.py#L880-885)) What happens if you try `import graph_tool.draw.cairo_draw`? Maybe there are additional dependencices you need to install via `apt-get` first. – Stuart Berg Mar 22 '21 at 15:00

2 Answers2

0

The commands below worked for me. The problem was because of some dependencies with cairo lib.

!apt-get install libcairo2-dev 
!pip install pycairo

Looking for the logs, I also noted that import gi had a link fault. It was introduced too.

!sudo echo "deb http://downloads.skewed.de/apt bionic main" >> /etc/apt/sources.list
!sudo apt-key adv --keyserver keys.openpgp.org --recv-key 612DEFB798507F25
!sudo apt-get update
!sudo apt-get install python3-graph-tool python3-matplotlib
!sudo ln -s /usr/lib/python3/dist-packages/gi/_gi.cpython-{36m,37m}-x86_64-linux-gnu.so
0

I have met the same issue and I found a solution to fix it. First of all, you have to downgrade the python version to 3.7(In cola, it is 3.10 as default) Then, install all dependencies in other above answers. And then,

apt-get install python3-cairo

For me , it does work

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '23 at 12:04