{"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":"python","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,"search_vec":"'2.0.2':50 '2014':57 'act':12 'activ':63 'allow':23 'cadenc':65 'creat':27 'current':47 'decemb':56 'defin':32 'develop':64 'dot':10,35,69 'format':43 'graph':31,66 'graphviz':8,45,67 'imag':42 'improv':15 'indic':58 'interfac':6 'languag':11,36 'last':53 'mainten':60 'manipul':30 'origin':19 'programmat':26 'project':21 'pydot':20 'pydotplus':1,2 'python':5 'rather':61 'read':28 'releas':54 'render':38 'use':44 'user':24 'various':41 'version':16,48 'visual':68","created_at":"2026-04-15T18:43:13.487379+00:00","updated_at":"2026-04-16T18:25:42.455849+00:00","problems":[{"fix":"1. Install Graphviz: Download and install Graphviz from its official website (graphviz.org/download/).\n2. Add to PATH: Ensure the directory containing Graphviz executables (e.g., C:\\Program Files\\Graphviz\\bin on Windows or /usr/local/bin on Linux/macOS) is added to your system's PATH environment variable. You might need to restart your terminal or IDE for changes to take effect.\n3. (Optional, in-script fix for Windows paths with spaces): If Graphviz is in a path with spaces (like 'C:\\Program Files'), you can sometimes explicitly set the path in your script:\n   ```python\n   import os\n   os.environ[\"PATH\"] += os.pathsep + 'C:\\\\Program Files\\\\Graphviz\\\\bin'\n   import pydotplus\n   ```","cause":"PyDotPlus is a Python wrapper for Graphviz. This error indicates that the underlying Graphviz executables (like `dot`) are either not installed on your system or their location is not added to your system's PATH environment variable, preventing pydotplus from calling them.","error":"GraphViz's executables not found"},{"fix":"Install the package using pip: `pip install pydotplus`. If using a Jupyter Notebook or similar, try `%pip install pydotplus` or `!pip install pydotplus`. If you have multiple Python versions, ensure you are installing it for the correct Python interpreter (e.g., `python3 -m pip install pydotplus`).","cause":"The `pydotplus` Python package has not been installed in the Python environment you are currently using, or there's a conflict with multiple Python installations.","error":"ModuleNotFoundError: No module named 'pydotplus'"},{"fix":"Access the function through its correct module path: `pydotplus.graphviz.graph_from_dot_data()`.\n   ```python\n   import pydotplus\n   graph = pydotplus.graphviz.graph_from_dot_data('digraph {a -> b}')\n   ```","cause":"The `graph_from_dot_data` function is not directly available under the top-level `pydotplus` module. It resides within the `pydotplus.graphviz` submodule.","error":"AttributeError: module 'pydotplus' has no attribute 'graph_from_dot_data'"},{"fix":"Explicitly add the Graphviz `bin` directory to the PATH environment variable within your Python script, making sure to escape backslashes correctly. This often resolves the quoting issue.\n   ```python\n   import os\n   # Replace with your actual Graphviz bin path\n   graphviz_bin_path = 'C:\\\\Program Files\\\\Graphviz\\\\bin'\n   os.environ[\"PATH\"] += os.pathsep + graphviz_bin_path\n   import pydotplus\n   # Your pydotplus code here\n   ```\n   Alternatively, install Graphviz to a path without spaces if possible.","cause":"This specific `InvocationException` typically occurs on Windows when the Graphviz installation path includes spaces (e.g., 'C:\\Program Files'), and pydotplus fails to properly quote the path when calling the Graphviz executables, leading to the command-line interpreter misinterpreting the path.","error":"InvocationException: Program terminated with status: 1. stderr follows: 'C:\\Program' is not recognized as an internal or external command, operable program or batch file."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.0.2","cli_name":"","cli_version":null,"type":"library","homepage":"http://pydotplus.readthedocs.org/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/pydotplus/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization","observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}