我是python的初学者,我正在尝试使用以下方法绘制图形:
`nx.write_dot(G, "%s.dot"%(image))`
在定义的函数中。当我执行程序时,我收到了这个错误:
File "sim.py", line 31, in <module>
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 "<decorator-gen-232>", 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'
这似乎是一个 Windows 操作系统问题(我在 win7 上),因为我的同事可以在他的 ubuntu 机器上运行相同的脚本而没有任何错误。
谢谢你的帮助!