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版本以后又会出现其他不兼容的问题,请问有没有其他的解决方法呢?

改用 from_numpy_array 看看