RussTedrake / manipulation

Course notes for MIT manipulation class
BSD 3-Clause "New" or "Revised" License
392 stars 115 forks source link

RenderDiagram from manipulation.utils errors running locally #311

Open jtcook2 opened 2 months ago

jtcook2 commented 2 months ago

I'm working through the homework problems in Chapter2. I was able to successfully run problem 2.1 in Deepnote. However, when I try to run the Jupyter notebook locally in VS code I get the following error.

`FileNotFoundError Traceback (most recent call last) File ~/src/test_robots/env/lib/python3.11/site-packages/pydot/core.py:1753, in Dot.create(self, prog, format, encoding) 1752 try: -> 1753 stdout_data, stderr_data, process = call_graphviz( 1754 program=prog, 1755 arguments=arguments, 1756 working_dir=tmp_dir, 1757 ) 1758 except OSError as e:

File ~/src/test_robots/env/lib/python3.11/site-packages/pydot/core.py:133, in call_graphviz(program, arguments, working_dir, kwargs) 131 program_with_args = [program] + arguments --> 133 process = subprocess.Popen( 134 program_with_args, 135 env=env, 136 cwd=working_dir, 137 shell=False, 138 stderr=subprocess.PIPE, 139 stdout=subprocess.PIPE, 140 kwargs, 141 ) 142 stdout_data, stderr_data = process.communicate()

File /opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:1026, in Popen.init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group) 1023 self.stderr = io.TextIOWrapper(self.stderr, 1024 encoding=encoding, errors=errors) -> 1026 self._execute_child(args, executable, preexec_fn, close_fds, 1027 pass_fds, cwd, env, 1028 startupinfo, creationflags, shell, 1029 p2cread, p2cwrite, 1030 c2pread, c2pwrite, 1031 errread, errwrite, 1032 restore_signals, 1033 gid, gids, uid, umask, 1034 start_new_session, process_group) 1035 except: 1036 # Cleanup if the child failed starting.

File /opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group) 1954 if err_filename is not None: -> 1955 raise child_exception_type(errno_num, err_msg, err_filename) 1956 else:

FileNotFoundError: [Errno 2] No such file or directory: 'dot'

During handling of the above exception, another exception occurred:

FileNotFoundError Traceback (most recent call last) Cell In[29], line 2 1 gains = [5, 2, 1] ----> 2 simulator, logger = BuildAndSimulate(0.0, p, gains, visualize=True)

Cell In[27], line 31, in BuildAndSimulate(q_d, pendulum_params, gains, visualize) 29 # Plot the diagram if visualize is true. 30 if visualize and running_as_notebook: ---> 31 RenderDiagram(diagram, max_depth=1) 33 simulator = Simulator(diagram) 34 context = simulator.get_mutable_context()

File ~/src/test_robots/env/lib/python3.11/site-packages/manipulation/utils.py:158, in RenderDiagram(system, max_depth) 145 def RenderDiagram(system: System, max_depth: int = None): 146 """Use pydot to render the GraphViz diagram of the given system. 147 148 Args: (...) 152 block. Defaults to 1. 153 """ 154 display( 155 SVG( 156 pydot.graph_from_dot_data(system.GetGraphvizString(max_depth=max_depth))[ 157 0 --> 158 ].create_svg() 159 ) 160 )

File ~/src/test_robots/env/lib/python3.11/site-packages/pydot/core.py:1578, in Dot.init..new_method(f, prog, encoding) 1576 def new_method(f=frmt, prog=None, encoding=None): 1577 """Refer to docstring of method create.""" -> 1578 return self.create(format=f, prog=prog, encoding=encoding)

File ~/src/test_robots/env/lib/python3.11/site-packages/pydot/core.py:1762, in Dot.create(self, prog, format, encoding) 1760 args = list(e.args) 1761 args[1] = '"{prog}" not found in path.'.format(prog=prog) -> 1762 raise OSError(*args) 1763 else: 1764 raise

FileNotFoundError: [Errno 2] "dot" not found in path.`

It looks like pydot and graphviz are in the virtual environment after installing the manipulation package so I'm unsure of the cause.

RussTedrake commented 2 months ago

I think brew install gprof2dot should resolve that?

I've slightly shied away from telling everyone to run manipulation/setup/mac/install_prereqs.sh, but that would have installed it for you.