python - AttributeError: module 'graph_tool.draw' has no attribute 'draw_hierarchy' 运行我的代码时返回,这是不正确的
问题描述
我正在尝试运行一个使用图形工具的脚本,并且代码返回:
/usr/lib/python3/dist-packages/graph_tool/all.py:40: RuntimeWarning: Error importing draw module, proceeding nevertheless: No module named 'cairo._cairo'
warnings.warn(msg, RuntimeWarning)
Nuclear_Overhauser_effect
['the', 'nuclear', 'overhauser', 'effect', 'noe', 'is', 'the', 'transfer', 'of', 'nuclear']
Traceback (most recent call last):
File "/home/qhama/Desktop/hSBM_Topicmodel/graphtools_tut.py", line 39, in <module>
model.plot(filename='tmp.png', nedges=1000)
File "/home/qhama/Desktop/hSBM_Topicmodel/sbmtm.py", line 183, in plot
subsample_edges=nedges, hshortcuts=1, hide=0)
File "/usr/lib/python3/dist-packages/graph_tool/inference/nested_blockmodel.py", line 934, in draw
return graph_tool.draw.draw_hierarchy(self, **kwargs)
AttributeError: module 'graph_tool.draw' has no attribute 'draw_hierarchy'
尝试重新安装 cairo 和每个依赖项
# Creating an instance of the sbtm-class
model = sbmtm()
# We have to create the word document network from the corpus
model.make_graph(texts, documents=titles)
gt.seed_rng(32)
model.fit()
# Plot the result
model.plot(filename='tmp.png', nedges=1000)
model.topics(l=1, n=20)
解决方案
在运行代码之前尝试导入所有 graph_tool 子模块,它可能会起作用。它对我有用。
import graph_tool.all as gt
推荐阅读
- swift - 使用 Swift 关闭 SFSafariViewController 时是否可以编辑动画?
- r - NanoStringDiff 计数不被识别为数字
- python - 无论如何在龟蟒中做类似 list[select_all] 的事情吗?
- php - 将 SQL 结果中的值添加到数组中
- email - 对 Microsoft 托管的电子邮件服务进行双重身份验证的 Alpine 电子邮件客户端
- r - 使用循环通过定义文件路径的数据框解压缩文件
- python - Python:如何根据类型进行强制转换,而不需要导入我们需要验证类型的对象
- javascript - stripe.confirmCardPayment 意图秘密 返回空字符串
- javascript - KnexJS 选择当年的所有记录
- android - httpClient.get 在模拟器上可以,但在安卓设备上不行