iwatake2222 / dear_ros_node_viewer

Dear RosNodeViewer: Visualize ROS2 Node Graph
https://pypi.org/project/dear-ros-node-viewer/
Apache License 2.0
119 stars 4 forks source link

Error occurs when loading dot graph file #16

Closed iwatake2222 closed 3 weeks ago

iwatake2222 commented 3 weeks ago

Issue

AttributeError: module 'pydot' has no attribute 'quote_id_if_necessary'. Did you mean: 'quote_if_necessary'? error occurs when loading a dot graph file or running ROS -> Load current graph

[INFO   ][ros2networkx.py:55] Analyzing...
[INFO   ][dot2networkx.py:99] len(connected_nodes) = 100
[INFO   ][graph_manager.py:98] 10 topics are removed by filter
[INFO   ][graph_manager.py:102] 5 nodes are removed due to isolated
[INFO   ][graph_manager.py:85] 0 nodes are removed by filter
Traceback (most recent call last):
  File "~/.local/lib/python3.10/site-packages/dear_ros_node_viewer/graph_view.py", line 310, in _cb_menu_graph_current
    self.graph_viewmodel.load_running_graph()
  File "~/.local/lib/python3.10/site-packages/dear_ros_node_viewer/graph_viewmodel.py", line 68, in load_running_graph
    self.graph_manager.load_graph_from_running_ros()
  File "~/.local/lib/python3.10/site-packages/dear_ros_node_viewer/graph_manager.py", line 57, in load_graph_from_running_ros
    self.load_graph_from_dot('./temp.dot')
  File "~/.local/lib/python3.10/site-packages/dear_ros_node_viewer/graph_manager.py", line 50, in load_graph_from_dot
    self.load_graph_postprocess(filename)
  File "~/.local/lib/python3.10/site-packages/dear_ros_node_viewer/graph_manager.py", line 72, in load_graph_postprocess
    self.graph = place_node_by_group(self.graph, self.group_setting)
  File "~/.local/lib/python3.10/site-packages/dear_ros_node_viewer/graph_layout.py", line 51, in place_node_by_group
    layout = place_node(graph, group_name)
  File "~/.local/lib/python3.10/site-packages/dear_ros_node_viewer/graph_layout.py", line 105, in place_node
    layout = nx.nx_pydot.pydot_layout(graph_modified, prog=prog)
  File "~/.local/lib/python3.10/site-packages/networkx/drawing/nx_pydot.py", line 344, in pydot_layout
    node = Q.get_node(pydot.quote_id_if_necessary(str_n))
AttributeError: module 'pydot' has no attribute 'quote_id_if_necessary'. Did you mean: 'quote_if_necessary'?

Environment

Cause

The issue is caused by the lack of compatibility between the versions used in the networkx package and the pydot package.

Solution

pip3 install pydot -U
pip3 install networkx -U
$ pip3 list | grep -e networkx -e pydot
networkx                             3.4.1
pydot                                3.0.2
iwatake2222 commented 3 weeks ago

The cause and solution is added into the issue description.