0

I just started programming and I'm trying to follow along in this book: "Natural Language Processing with Python (2009)," but I can't seem to find a solution to this error. I think this graph_viz issue has been discussed before, but I'm also aware that the rules of syntax can change. It's supposed to show a cool-looking visualization. Is this a module or syntax problem?

import networkx as nx
import matplotlib
from nltk.corpus import wordnet as wn
def traverse(graph, start, node): 
    graph.depth[node.name] =
node.shortest_path_distance(start)
        graph.add_edge(node.name, child.name)
        traverse(graph, start, child)

def hyponym_graph(start):
    G = nx.Graph()
    G.depth = {}
    traverse(G, start, start)
    return G

def graph_draw(graph):
    nx.draw_graphviz(graph,
        node_size = [16 * graph.degree(n) for n in graph],
        node_color = [graph.depth[n] for n in graoh],
        with_labels = False)
matplotlib.pyplot.show()

dog = wn.synset('dog.n.01')
graph = hyponym_graph(dog)
graph_draw(graph)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in graph_draw
AttributeError: module 'networkx' has no attribute 'draw_graphviz'
  • https://stackoverflow.com/questions/41047362/python-networkx-error-module-networkx-drawing-has-no-attribute-graphviz-layo – Lydia van Dyke Dec 29 '20 at 22:44
  • Does this answer your question? [Python NetworkX error: module 'networkx.drawing' has no attribute 'graphviz\_layout'](https://stackoverflow.com/questions/41047362/python-networkx-error-module-networkx-drawing-has-no-attribute-graphviz-layo) – Untitled123 Dec 29 '20 at 23:58

1 Answers1

0

It appears to have been removed in version 2.0 in order to fix a bug. The change notes are here

Joe
  • 399
  • 2
  • 7