{"library":"pydot","title":"Pydot","description":"Pydot is a pure-Python interface to Graphviz and its DOT language, enabling users to programmatically create, read, edit, and visualize graphs. It is currently at version 4.0.1 and is actively maintained with a regular release cadence, with recent updates focusing on parser fixes and type annotations.","status":"active","version":"4.0.1","language":"en","source_language":"en","source_url":"https://github.com/pydot/pydot","tags":["graph visualization","graphviz","dot language","data structures","networkx"],"install":[{"cmd":"pip install pydot","lang":"bash","label":"Install pydot"},{"cmd":"# You *must* also install Graphviz separately on your system.\n# For Debian/Ubuntu:\nsudo apt install graphviz\n# For macOS (with Homebrew):\nbrew install graphviz\n# For Windows, download from graphviz.org/download/ and add to PATH.","lang":"bash","label":"Install Graphviz (system dependency)"}],"dependencies":[{"reason":"Used for loading DOT files; installed automatically by pip.","package":"pyparsing","optional":false},{"reason":"Essential for rendering graphs into image formats (e.g., PNG, SVG, PDF); must be installed separately at the system level.","package":"Graphviz","optional":false}],"imports":[{"symbol":"pydot","correct":"import pydot"},{"symbol":"Dot","correct":"import pydot\ngraph = pydot.Dot(...)"},{"symbol":"Node","correct":"import pydot\nnode = pydot.Node(...)"},{"symbol":"Edge","correct":"import pydot\nedge = pydot.Edge(...)"}],"quickstart":{"code":"import pydot\nimport os\n\n# Ensure Graphviz dot executable is found. On some systems or environments,\n# pydot might not find it automatically. This is for demonstration; usually,\n# ensuring Graphviz is in PATH is enough.\n# You might need to set this if Graphviz is installed in a non-standard location.\n# For example, on Windows: os.environ[\"PATH\"] += os.pathsep + 'C:/Program Files/Graphviz/bin'\n\ngraph = pydot.Dot('my_graph', graph_type='digraph')\n\nnode_a = pydot.Node('A', style='filled', fillcolor='red')\nnode_b = pydot.Node('B', style='filled', fillcolor='blue')\nnode_c = pydot.Node('C')\n\ngraph.add_node(node_a)\ngraph.add_node(node_b)\ngraph.add_node(node_c)\n\ngraph.add_edge(pydot.Edge(node_a, node_b, label='edge_ab'))\ngraph.add_edge(pydot.Edge(node_b, node_c, label='edge_bc', color='green'))\ngraph.add_edge(pydot.Edge(node_c, node_a, label='edge_ca', arrowhead='vee'))\n\n# Save the graph to a PNG file\ntry:\n    graph.write_png('output_graph.png')\n    print(\"Graph saved to output_graph.png\")\nexcept pydot.InvocationException as e:\n    print(f\"Error generating graph: {e}\")\n    print(\"Make sure Graphviz is installed and its 'dot' executable is in your system PATH.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to create a directed graph using pydot, add nodes with custom styles, connect them with edges, and save the resulting visualization as a PNG image. It includes basic error handling for common Graphviz executable issues."},"warnings":[{"fix":"Install Graphviz on your operating system (e.g., `sudo apt install graphviz` on Debian/Ubuntu, `brew install graphviz` on macOS) and ensure its binaries are accessible via your system's PATH environment variable.","message":"Pydot relies on Graphviz for rendering graphs. If Graphviz is not installed separately on your system (beyond `pip install pydot`) and its `dot` executable is not in your system's PATH, pydot will raise an `InvocationException`.","severity":"breaking","affected_versions":"All versions of pydot"},{"fix":"Escape colons with a backslash (`\\:`) or enclose the entire label/name in quotes if it contains special characters, especially colons, to ensure Graphviz parses it correctly. For example, `pydot.Node('node:name')` might fail, but `pydot.Node('\"node:name\"')` or `pydot.Node('node\\:name')` should work.","message":"Using colons (:) directly in node names or edge labels without proper escaping can lead to Graphviz syntax errors when rendering, resulting in `InvocationException`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are installing and importing `pydot` (`pip install pydot`) and not `pydotplus` (`pip install pydotplus`) unless you have a specific dependency on the latter.","message":"There is a separate, older project called `pydotplus` which was an 'improved version of the old pydot project'. The current `pydot` (v4.0.1) is actively maintained and the recommended library. Using `pydotplus` might lead to outdated functionality or compatibility issues with modern Python versions or other libraries.","severity":"gotcha","affected_versions":"All versions where both libraries coexist"}],"env_vars":null,"last_verified":"2026-04-06T00:00:00.000Z","next_check":"2026-07-05T00:00:00.000Z"}