图时出现意外错误

图时出现意外错误

本文介绍了读取 GML 图时出现意外错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了包含 dolphins 社交网络的 gml 文件.

I have downloaded the gml file which contains the dolphins social network.

前段时间我对在 Windows7 机器上运行 python 3.4 和 networkx 1.9 的网络做了一些分析,但现在我在 Arch linux 机器上运行(使用相同版本的 python 但使用 networkx 1.10)并在尝试读取文件时发现问题.

Some time ago I did some analysis on that network running python 3.4 and networkx 1.9 on a a Windows7 machine, but now I am running on a Arch linux machine (with the same version of python but with networkx 1.10) and found an issue when tried to read the file.

这是用于读取文件的代码:

This is the code used to read the file:

import networkx as nx
nx.read_gml("dolphins.gml")

这是错误的堆栈跟踪:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 2, in read_gml
File "/usr/lib/python3.4/site-packages/networkx/utils/decorators.py",line 220, in _open_file
result = func(*new_args, **kwargs)
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 210, in read_gml
G = parse_gml_lines(filter_lines(path), label, destringizer)
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 383, in parse_gml_lines
graph = parse_graph()
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 372, in parse_graph
curr_token, dct = parse_kv(next(tokens))
File "/usr/lib/python3.4/site-packages/networkx/readwrite/gml.py", line 323, in tokenize
(line[pos:], lineno + 1, pos + 1))
networkx.exception.NetworkXError: cannot tokenize 'graph' at (1, 1)

你能读取文件吗?有人遇到过类似的问题吗?或者知道是什么导致了错误?

Are you able to read the file? Someone has experienced a simmilar issue? or knows what is generating the error?

先谢谢你!

推荐答案

它的工作原理是将 networkx 版本从 1.10 降级到 1.9.1.

It worked by downgrading the networkx version from 1.10 to 1.9.1.

希望这个答案可以帮助其他人.

Hope this answer can help someone else.

这篇关于读取 GML 图时出现意外错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 15:27