活蹦乱跳的小天音 2023-03-22 16:56 采纳率: 75%
浏览 357

networkx报错module 'networkx' has no attribute 'from_numpy_matrix'

第五行报错

from textrank4zh import TextRank4Sentence
tr4s = TextRank4Sentence()
path = r"D:\python test\70_ch-en_copyright_act\Chinese copyright law (2010-04-26)_chn.txt"
text = open(path, encoding='UTF-8-sig').read()
tr4s.analyze(text=text)
keySents = tr4s.get_key_sentences(num=10, sentence_min_len=41)
[(sent['weight'], sent['sentence']) for sent in keySents]

第五行tr4s.analyze(text=text)报错

img

查了一下说是networkx版本过高,from_numpy_matrix已经被删除,但是安装了networkx2.3版本以后又会出现其他不兼容的问题,请问有没有其他的解决方法呢?

  • 写回答

1条回答 默认 最新

  • threenewbee 2023-03-22 17:48
    关注

    改用 from_numpy_array 看看

    评论

报告相同问题?

问题事件

  • 创建了问题 3月22日