python - 'module' object has no attribute 'Dot' -


i'm beginner in python, , i'm trying draw graph using:

`nx.write_dot(g, "%s.dot"%(image))` 

in defined function. when excute program, i'm getting error:

file "sim.py", line 31, in main()

file "sim.py", line 30, in main sol.run()

file "c:\python27\my sim\solution.py", line 221, in run self.drawgraph(g, "solution1")

file "c:\python27\my sim\solution.py", line 227, in drawgraph nx.write_dot(g, "%s.dot"%(image))

file "", line 2, in write_dot

file "c:\python27\lib\site-packages\networkx\utils\decorators.py", line 220, in _open_file

result = func(*new_args, **kwargs)

file "c:\python27\lib\site-packages\networkx\drawing\nx_pydot.py", line 58, in write_dot

p=to_pydot(g)

file "c:\python27\lib\site-packages\networkx\drawing\nx_pydot.py", line 197, in to_pydot

p = pydot.dot(graph_type=graph_type,strict=strict,**graph_defaults) attributeerror: 'module' object has no attribute 'dot'

it seems windows os problem (i'm on win7), because colleague can run same script on ubuntu machine without error.

thanks help!

you doing tutorial drawing graphs right?

here how work:

import networkx nx import matplotlib.pyplot plt  g=nx.graph() g.add_edges_from([(1,2),(1,3)]) nx.draw(g) plt.show() 

edit: if didn't install matplotlib, open command line , type:

pip install matplotlib 

matplotlib optional, doesn't come networkx, have install it.

also saving .dot file add line:

nx.write_dot(g,'c:/file.dot') 

edit: without matplotlib so:

import networkx nx  g=nx.graph() g.add_edges_from([(1,2),(1,3)]) nx.draw(g) nx.write_dot(g,'c:/file.dot') 

i notice in code nx.write_dot(g, "%s.dot"%(image)) didn't define image , g, error should 1 of those.

but if want install c++ compiler, suggest downloading visual c++ compiler 33mb or microsoft visual studio community, free.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -