Networkx read_gml错误“networkx.exception.NetworkXError:can not tokenize u'graph'at(3,1)” [英] Networkx read_gml error "networkx.exception.NetworkXError: cannot tokenize u'graph' at (3, 1)"

查看:1541
本文介绍了Networkx read_gml错误“networkx.exception.NetworkXError:can not tokenize u'graph'at(3,1)”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用networkx读取gml文件(非常简单的权利?),除非每次尝试读取文件时,我都会收到错误networkx.exception.NetworkXError:can not tokenize u'graph' (3,1)我对gml或networkx不是很熟悉,所以我一直无法自己诊断问题。



甚至更奇怪的是我的同事会用完全相同的文件运行完全相同的命令,并且它会毫无错误地执行。我已经卸载并重新安装了networkx几次,任何人都可以帮助确定错误可能来自哪里?

  import networkx as nx 
g = nx.read_gml('disciplineNetwork.gml')

Traceback(大部分


文件,第1行,在

文件,第2行,在read_gml中



文件/usr/local/lib/python2.7/dist-packages/networkx/utils/decorators.py,第220行,在_open_file
result = func(* new_args,** kwargs)



文件/usr/local/lib/python2.7/dist- packages / networkx / readwrite / gml.py,第210行,在read_gml
G = parse_gml_lines(filter_lines(path),label,destringizer)

/usr/local/lib/python2.7/dist-packages/networkx/readwrite/gml.py,第383行,在parse_gml_lines中
graph = parse_graph()



文件/usr/local/lib/python2.7/dist-packages/netwo rkx / readwrite / gml.py,第372行,在parse_graph
curr_token,dct = parse_kv(next(tokens))

文件​​/ usr / local /lib/python2.7/dist-packages/networkx/readwrite/gml.py,第347行,在parse_kv中
curr_token = next(令牌)

文件/usr/local/lib/python2.7/dist-packages/networkx/readwrite/gml.py,行323,标记为
(line [pos:],lineno + 1,pos + 1) )



networkx.exception.NetworkXError:无法在(3,1)处标记u'graph'


解决方案

我遇到同样的问题,我的解决方案是降级networkx的版本。

这个问题


I'm trying to use networkx to read in a gml file (pretty simple right?), except whenever I try to read in the file, I get the error "networkx.exception.NetworkXError: cannot tokenize u'graph' at (3, 1)" I'm not too familiar with gml or networkx, so I haven't been able to diagnose the problem myself.

What's even weirder is that my coworker will run the exact same command with the exact same file, and it will execute without error. I've uninstalled and reinstalled networkx several times at this point, can anyone help determine what the error could be coming from?

import networkx as nx
g = nx.read_gml('disciplineNetwork.gml')

Traceback (most recent call last):

File "", line 1, in

File "", line 2, in read_gml

File "/usr/local/lib/python2.7/dist-packages/networkx/utils/decorators.py", line 220, in _open_file result = func(*new_args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/gml.py", line 210, in read_gml G = parse_gml_lines(filter_lines(path), label, destringizer)

File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/gml.py", line 383, in parse_gml_lines graph = parse_graph()

File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/gml.py", line 372, in parse_graph curr_token, dct = parse_kv(next(tokens))

File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/gml.py", line 347, in parse_kv curr_token = next(tokens)

File "/usr/local/lib/python2.7/dist-packages/networkx/readwrite/gml.py", line 323, in tokenize (line[pos:], lineno + 1, pos + 1))

networkx.exception.NetworkXError: cannot tokenize u'graph' at (3, 1)

解决方案

I had the same problem and the solution for me was downgrading the version of networkx.

See this question.

这篇关于Networkx read_gml错误“networkx.exception.NetworkXError:can not tokenize u'graph'at(3,1)”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆