{"id":6793,"library":"pydotplus","title":"pydotplus","description":"PyDotPlus is a Python interface to Graphviz's Dot language, acting as an improved version of the original `pydot` project. It allows users to programmatically create, read, and manipulate graphs defined in the DOT language and render them into various image formats using Graphviz. The current version is 2.0.2, with its last release in December 2014, indicating a maintenance rather than active development cadence.","status":"maintenance","version":"2.0.2","language":"en","source_language":"en","source_url":"https://github.com/carlos-jenkins/pydotplus","tags":["graph","graphviz","visualization","dot"],"install":[{"cmd":"pip install pydotplus","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for parsing DOT files. Automatically installed with pydotplus.","package":"pyparsing"},{"reason":"External software required for rendering graphs into image formats (PNG, SVG, PDF, etc.). Must be installed separately and its executables added to system PATH.","package":"Graphviz","optional":false}],"imports":[{"note":"While direct import is possible, `import pydotplus` and using `pydotplus.Dot()` is the most common and robust pattern.","wrong":"from pydotplus import Dot","symbol":"Dot","correct":"import pydotplus\ngraph = pydotplus.Dot()"},{"symbol":"graph_from_dot_data","correct":"import pydotplus\ngraph = pydotplus.graph_from_dot_data(dot_string)"}],"quickstart":{"code":"import pydotplus\nimport os\n\n# Create a directed graph\ngraph = pydotplus.Dot(graph_type='digraph')\n\n# Add nodes\nnode_a = pydotplus.Node(\"A\", style=\"filled\", fillcolor=\"red\")\nnode_b = pydotplus.Node(\"B\", style=\"filled\", fillcolor=\"green\")\nnode_c = pydotplus.Node(\"C\", style=\"filled\", fillcolor=\"blue\")\n\ngraph.add_node(node_a)\ngraph.add_node(node_b)\ngraph.add_node(node_c)\n\n# Add edges\nedge_ab = pydotplus.Edge(\"A\", \"B\", label=\"connects\")\nedge_bc = pydotplus.Edge(\"B\", \"C\", arrowhead=\"open\")\n\ngraph.add_edge(edge_ab)\ngraph.add_edge(edge_bc)\n\n# Try to save the graph to a file\ntry:\n    # This requires Graphviz to be installed and its executables in the system PATH\n    output_file = \"simple_graph.png\"\n    graph.write_png(output_file)\n    print(f\"Graph '{output_file}' created successfully.\")\nexcept pydotplus.graphviz.InvocationException as e:\n    print(f\"Error: Graphviz executables not found or not in PATH. {e}\")\n    print(\"Please install Graphviz (https://graphviz.org/download/) and add its 'bin' directory to your system's PATH environment variable.\")\n    print(\"For example, on Windows: ';C:\\Program Files (x86)\\Graphviz2.38\\bin' should be added to PATH.\")\n    print(\"On Linux/macOS, ensure Graphviz is installed via package manager and 'dot' command is accessible.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n\n# Example of loading from DOT data\ndot_data = \"digraph { A -> B; B -> C; }\"\nloaded_graph = pydotplus.graph_from_dot_data(dot_data)\n# loaded_graph.write_svg(\"loaded_graph.svg\") # Uncomment to save","lang":"python","description":"This quickstart demonstrates how to create a simple directed graph with nodes and edges using `pydotplus` and then attempts to render it to a PNG image. It also includes an example of loading a graph from a DOT string. **Crucially, for the rendering step to succeed, Graphviz must be installed on your system and its `bin` directory must be added to your system's PATH environment variable.**"},"warnings":[{"fix":"Download and install Graphviz from https://graphviz.org/download/. After installation, add the path to its 'bin' directory (e.g., `C:\\Program Files\\Graphviz\\bin` on Windows or `/usr/local/bin/` on macOS/Linux if installed via Homebrew/apt) to your system's PATH environment variable. Restart your terminal/IDE after modifying PATH.","message":"Graphviz must be installed separately and its executables must be in your system's PATH environment variable. Failure to do so will result in `pydotplus.graphviz.InvocationException: GraphViz's executables not found` when attempting to render graphs.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure the Graphviz installation path added to your PATH environment variable is properly quoted if it contains spaces, or ideally, install Graphviz to a path without spaces (e.g., `C:\\Graphviz`). Alternatively, some users report success by modifying `pydotplus`'s internal `graphviz.py` to add quotes around executable paths, but this is a hacky solution.","message":"When running on Windows, if the Graphviz installation path contains spaces (e.g., `C:\\Program Files (x86)\\Graphviz...`), you might encounter `InvocationException: 'C:\\Program' is not recognized as an internal or external command`. This is due to how subprocesses handle unquoted paths.","severity":"gotcha","affected_versions":"All versions, primarily Windows users"},{"fix":"If starting a new project or migrating, prefer `pydotplus` for better Python 3 compatibility. Ensure you only install one of them to avoid potential conflicts in import paths or runtime behavior, although they typically import as `pydotplus` and `pydot` respectively.","message":"Confusion between `pydot` and `pydotplus` is common. `pydotplus` was created as an actively maintained fork to address issues in `pydot`, particularly Python 3 compatibility and `pyparsing` version support, during a period when `pydot` development was stalled.","severity":"gotcha","affected_versions":"Users transitioning from or concurrently using `pydot`"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}