gpt4 book ai didi

python - Networkx read_gml 错误 "networkx.exception.NetworkXError: cannot tokenize u' 图在 (3, 1)”

转载 作者:太空狗 更新时间:2023-10-29 21:07:04 34 4
gpt4 key购买 nike

我正在尝试使用 networkx 读取 gml 文件(很简单吧?),除非我尝试读取文件时出现错误“networkx.exception.NetworkXError: cannot tokenize u'graph' at (3, 1)"我对 gml 或 networkx 不太熟悉,所以我无法自己诊断问题。

更奇怪的是,我的同事将使用完全相同的文件运行完全相同的命令,而且它会毫无错误地执行。此时我已经多次卸载并重新安装 networkx,任何人都可以帮助确定错误可能来自什么?

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

追溯(最近的调用最后):

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)

最佳答案

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

参见 this question .

关于python - Networkx read_gml 错误 "networkx.exception.NetworkXError: cannot tokenize u' 图在 (3, 1)”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31946029/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com