在Google CoLab上安装图形工具包时出现问题

2022-03-15 00:00:00 python google-colaboratory graph-tool

问题描述

我遵循了以下链接(https://colab.research.google.com/github/count0/colab-gt/blob/master/colab-gt.ipynb#scrollTo=d_j7nNbKRmhx)中的图形工具安装说明。但是,它会抛出以下错误


<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' ```

解决方案

下面的命令对我有效。该问题是由于与cairo库的某些依赖关系造成的。

!apt-get install libcairo2-dev 
!pip install pycairo
查找日志时,我还注意到导入gi有一个链接故障。它也被介绍了。

!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

相关文章