We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Better error messaging when graphviz is not present
_For reference, this was originally posted by @jaygambetta in https://github.com/Qiskit/qiskit-terra/issues/2281#issuecomment-489417445_

> @ajavadia and @mtreinish  it has been lost where to find how to add this dependencies outside pip. It is in the doc for the function https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/visualization/dag_visualization.py but I think we need to make this clearer in the documentation in the Qiskit repo. 
>
> I would split this into two issues -- 
> 1. In terra add better error messaging. If you call drag_drawer and you don't have graphviz give that this dependency needs to be installed on your system. 
> 2. in qiskit add a documentation on how to setup the dag drawer for different operating systems.

This is issue is about the first item. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `qiskit/visualization/dag_visualization.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # This code is part of Qiskit.
4 #
5 # (C) Copyright IBM 2017, 2018.
6 #
7 # This code is licensed under the Apache License, Version 2.0. You may
8 # obtain a copy of this license in the LICENSE.txt file in the root directory
9 # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
10 #
11 # Any modifications or derivative works of this code must retain this
12 # copyright notice, and modified files need to carry a notice indicating
13 # that they have been altered from the originals.
14 
15 # pylint: disable=invalid-name
16 
17 """
18 Visualization function for DAG circuit representation.
19 """
20 
21 import sys
22 from .exceptions import VisualizationError
23 
24 
25 def dag_drawer(dag, scale=0.7, filename=None, style='color'):
26     """Plot the directed acyclic graph (dag) to represent operation dependencies
27     in a quantum circuit.
28 
29     Note this function leverages
30     `pydot <https://github.com/erocarrera/pydot>`_ (via
31     `nxpd <https://github.com/chebee7i/nxpd`_) to generate the graph, which
32     means that having `Graphviz <https://www.graphviz.org/>`_ installed on your
33     system is required for this to work.
34 
35     Args:
36         dag (DAGCircuit): The dag to draw.
37         scale (float): scaling factor
38         filename (str): file path to save image to (format inferred from name)
39         style (str): 'plain': B&W graph
40                      'color' (default): color input/output/op nodes
41 
42     Returns:
43         Ipython.display.Image: if in Jupyter notebook and not saving to file,
44             otherwise None.
45 
46     Raises:
47         VisualizationError: when style is not recognized.
48         ImportError: when nxpd or pydot not installed.
49     """
50     try:
51         import nxpd
52         import pydot  # pylint: disable=unused-import
53     except ImportError:
54         raise ImportError("dag_drawer requires nxpd, pydot, and Graphviz. "
55                           "Run 'pip install nxpd pydot', and install graphviz")
56 
57     G = dag.to_networkx()
58     G.graph['dpi'] = 100 * scale
59 
60     if style == 'plain':
61         pass
62     elif style == 'color':
63         for node in G.nodes:
64             n = G.nodes[node]
65             n['label'] = node.name
66             if node.type == 'op':
67                 n['color'] = 'blue'
68                 n['style'] = 'filled'
69                 n['fillcolor'] = 'lightblue'
70             if node.type == 'in':
71                 n['color'] = 'black'
72                 n['style'] = 'filled'
73                 n['fillcolor'] = 'green'
74             if node.type == 'out':
75                 n['color'] = 'black'
76                 n['style'] = 'filled'
77                 n['fillcolor'] = 'red'
78         for e in G.edges(data=True):
79             e[2]['label'] = e[2]['name']
80     else:
81         raise VisualizationError("Unrecognized style for the dag_drawer.")
82 
83     if filename:
84         show = False
85     elif ('ipykernel' in sys.modules) and ('spyder' not in sys.modules):
86         show = 'ipynb'
87     else:
88         show = True
89 
90     return nxpd.draw(G, filename=filename, show=show)
91
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/qiskit/visualization/dag_visualization.py b/qiskit/visualization/dag_visualization.py
--- a/qiskit/visualization/dag_visualization.py
+++ b/qiskit/visualization/dag_visualization.py
@@ -51,8 +51,8 @@
         import nxpd
         import pydot  # pylint: disable=unused-import
     except ImportError:
-        raise ImportError("dag_drawer requires nxpd, pydot, and Graphviz. "
-                          "Run 'pip install nxpd pydot', and install graphviz")
+        raise ImportError("dag_drawer requires nxpd and pydot. "
+                          "Run 'pip install nxpd pydot'.")
 
     G = dag.to_networkx()
     G.graph['dpi'] = 100 * scale
@@ -87,4 +87,9 @@
     else:
         show = True
 
-    return nxpd.draw(G, filename=filename, show=show)
+    try:
+        return nxpd.draw(G, filename=filename, show=show)
+    except nxpd.pydot.InvocationException:
+        raise VisualizationError("dag_drawer requires GraphViz installed in the system. "
+                                 "Check https://www.graphviz.org/download/ for details on "
+                                 "how to install GraphViz in your system.")

{"golden_diff": "diff --git a/qiskit/visualization/dag_visualization.py b/qiskit/visualization/dag_visualization.py\n--- a/qiskit/visualization/dag_visualization.py\n+++ b/qiskit/visualization/dag_visualization.py\n@@ -51,8 +51,8 @@\n         import nxpd\n         import pydot  # pylint: disable=unused-import\n     except ImportError:\n-        raise ImportError(\"dag_drawer requires nxpd, pydot, and Graphviz. \"\n-                          \"Run 'pip install nxpd pydot', and install graphviz\")\n+        raise ImportError(\"dag_drawer requires nxpd and pydot. \"\n+                          \"Run 'pip install nxpd pydot'.\")\n \n     G = dag.to_networkx()\n     G.graph['dpi'] = 100 * scale\n@@ -87,4 +87,9 @@\n     else:\n         show = True\n \n-    return nxpd.draw(G, filename=filename, show=show)\n+    try:\n+        return nxpd.draw(G, filename=filename, show=show)\n+    except nxpd.pydot.InvocationException:\n+        raise VisualizationError(\"dag_drawer requires GraphViz installed in the system. \"\n+                                 \"Check https://www.graphviz.org/download/ for details on \"\n+                                 \"how to install GraphViz in your system.\")\n", "issue": "Better error messaging when graphviz is not present\n_For reference, this was originally posted by @jaygambetta in https://github.com/Qiskit/qiskit-terra/issues/2281#issuecomment-489417445_\r\n\r\n> @ajavadia and @mtreinish  it has been lost where to find how to add this dependencies outside pip. It is in the doc for the function https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/visualization/dag_visualization.py but I think we need to make this clearer in the documentation in the Qiskit repo. \r\n>\r\n> I would split this into two issues -- \r\n> 1. In terra add better error messaging. If you call drag_drawer and you don't have graphviz give that this dependency needs to be installed on your system. \r\n> 2. in qiskit add a documentation on how to setup the dag drawer for different operating systems.\r\n\r\nThis is issue is about the first item. \n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017, 2018.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n# pylint: disable=invalid-name\n\n\"\"\"\nVisualization function for DAG circuit representation.\n\"\"\"\n\nimport sys\nfrom .exceptions import VisualizationError\n\n\ndef dag_drawer(dag, scale=0.7, filename=None, style='color'):\n    \"\"\"Plot the directed acyclic graph (dag) to represent operation dependencies\n    in a quantum circuit.\n\n    Note this function leverages\n    `pydot <https://github.com/erocarrera/pydot>`_ (via\n    `nxpd <https://github.com/chebee7i/nxpd`_) to generate the graph, which\n    means that having `Graphviz <https://www.graphviz.org/>`_ installed on your\n    system is required for this to work.\n\n    Args:\n        dag (DAGCircuit): The dag to draw.\n        scale (float): scaling factor\n        filename (str): file path to save image to (format inferred from name)\n        style (str): 'plain': B&W graph\n                     'color' (default): color input/output/op nodes\n\n    Returns:\n        Ipython.display.Image: if in Jupyter notebook and not saving to file,\n            otherwise None.\n\n    Raises:\n        VisualizationError: when style is not recognized.\n        ImportError: when nxpd or pydot not installed.\n    \"\"\"\n    try:\n        import nxpd\n        import pydot  # pylint: disable=unused-import\n    except ImportError:\n        raise ImportError(\"dag_drawer requires nxpd, pydot, and Graphviz. \"\n                          \"Run 'pip install nxpd pydot', and install graphviz\")\n\n    G = dag.to_networkx()\n    G.graph['dpi'] = 100 * scale\n\n    if style == 'plain':\n        pass\n    elif style == 'color':\n        for node in G.nodes:\n            n = G.nodes[node]\n            n['label'] = node.name\n            if node.type == 'op':\n                n['color'] = 'blue'\n                n['style'] = 'filled'\n                n['fillcolor'] = 'lightblue'\n            if node.type == 'in':\n                n['color'] = 'black'\n                n['style'] = 'filled'\n                n['fillcolor'] = 'green'\n            if node.type == 'out':\n                n['color'] = 'black'\n                n['style'] = 'filled'\n                n['fillcolor'] = 'red'\n        for e in G.edges(data=True):\n            e[2]['label'] = e[2]['name']\n    else:\n        raise VisualizationError(\"Unrecognized style for the dag_drawer.\")\n\n    if filename:\n        show = False\n    elif ('ipykernel' in sys.modules) and ('spyder' not in sys.modules):\n        show = 'ipynb'\n    else:\n        show = True\n\n    return nxpd.draw(G, filename=filename, show=show)\n", "path": "qiskit/visualization/dag_visualization.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017, 2018.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n# pylint: disable=invalid-name\n\n\"\"\"\nVisualization function for DAG circuit representation.\n\"\"\"\n\nimport sys\nfrom .exceptions import VisualizationError\n\n\ndef dag_drawer(dag, scale=0.7, filename=None, style='color'):\n    \"\"\"Plot the directed acyclic graph (dag) to represent operation dependencies\n    in a quantum circuit.\n\n    Note this function leverages\n    `pydot <https://github.com/erocarrera/pydot>`_ (via\n    `nxpd <https://github.com/chebee7i/nxpd`_) to generate the graph, which\n    means that having `Graphviz <https://www.graphviz.org/>`_ installed on your\n    system is required for this to work.\n\n    Args:\n        dag (DAGCircuit): The dag to draw.\n        scale (float): scaling factor\n        filename (str): file path to save image to (format inferred from name)\n        style (str): 'plain': B&W graph\n                     'color' (default): color input/output/op nodes\n\n    Returns:\n        Ipython.display.Image: if in Jupyter notebook and not saving to file,\n            otherwise None.\n\n    Raises:\n        VisualizationError: when style is not recognized.\n        ImportError: when nxpd or pydot not installed.\n    \"\"\"\n    try:\n        import nxpd\n        import pydot  # pylint: disable=unused-import\n    except ImportError:\n        raise ImportError(\"dag_drawer requires nxpd and pydot. \"\n                          \"Run 'pip install nxpd pydot'.\")\n\n    G = dag.to_networkx()\n    G.graph['dpi'] = 100 * scale\n\n    if style == 'plain':\n        pass\n    elif style == 'color':\n        for node in G.nodes:\n            n = G.nodes[node]\n            n['label'] = node.name\n            if node.type == 'op':\n                n['color'] = 'blue'\n                n['style'] = 'filled'\n                n['fillcolor'] = 'lightblue'\n            if node.type == 'in':\n                n['color'] = 'black'\n                n['style'] = 'filled'\n                n['fillcolor'] = 'green'\n            if node.type == 'out':\n                n['color'] = 'black'\n                n['style'] = 'filled'\n                n['fillcolor'] = 'red'\n        for e in G.edges(data=True):\n            e[2]['label'] = e[2]['name']\n    else:\n        raise VisualizationError(\"Unrecognized style for the dag_drawer.\")\n\n    if filename:\n        show = False\n    elif ('ipykernel' in sys.modules) and ('spyder' not in sys.modules):\n        show = 'ipynb'\n    else:\n        show = True\n\n    try:\n        return nxpd.draw(G, filename=filename, show=show)\n    except nxpd.pydot.InvocationException:\n        raise VisualizationError(\"dag_drawer requires GraphViz installed in the system. \"\n                                 \"Check https://www.graphviz.org/download/ for details on \"\n                                 \"how to install GraphViz in your system.\")\n", "path": "qiskit/visualization/dag_visualization.py"}]}