Registry / serialization / pydot-ng

pydot-ng

JSON →
library2.0.0pypypi✓ verified 87d ago

Pydot-ng is an archived Python interface to Graphviz's Dot language, enabling programmatic creation, manipulation, and rendering of graphs. It was originally created to provide Python 2 and 3 compatibility as a fork of the original pydot. The last stable version is 2.0.0, released in October 2018. This project is no longer actively maintained, and users are strongly advised to use the actively developed `pydot` library instead.

pip install pydot-ng
INSTALL
IMPORT
SIG · PYDOT-NG
P
pydot-ng
serializationpythonv2.0.0
Install
1.6s avg
Import
300ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.317s · 18.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.282s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pydot_ng
import pydot_ng
import pydot
While 'import pydot_ng as pydot' was a common pattern for API compatibility with the original pydot, direct import is 'pydot_ng'. However, given the project's archived status, it's recommended to use the actively maintained `pydot` library directly (i.e., `import pydot`).
Graph
from pydot_ng import Graph
This would be the correct way to import the Graph class from pydot-ng, though using `import pydot_ng as pydot` and then `pydot.Graph` was more common for compatibility.
Node
from pydot_ng import Node
This would be the correct way to import the Node class from pydot-ng.
Edge
from pydot_ng import Edge
This would be the correct way to import the Edge class from pydot-ng.

This quickstart demonstrates how to create a simple directed graph with nodes and edges using pydot-ng and save it as a PNG image. It includes important warnings about the project's archived status and the Graphviz system dependency. For new projects, use the 'pydot' library.

import pydot_ng as pydot import os # NOTE: pydot-ng is archived. It is highly recommended to use 'pydot' instead. # For Graphviz to work, ensure it is installed on your system and 'dot' is in your PATH. # On Linux: sudo apt-get install graphviz # On macOS: brew install graphviz # On Windows: Download from graphviz.org and add 'bin' to PATH. # Create a graph graph = pydot.Dot('my_graph', graph_type='digraph') # Add nodes node_a = pydot.Node('A', style='filled', fillcolor='red') node_b = pydot.Node('B', style='filled', fillcolor='green') node_c = pydot.Node('C', style='filled', fillcolor='blue') graph.add_node(node_a) graph.add_node(node_b) graph.add_node(node_c) # Add edges graph.add_edge(pydot.Edge(node_a, node_b)) graph.add_edge(pydot.Edge(node_b, node_c, label='Connects')) # Save the graph to a file try: # Using a temporary file for demonstration output_file = 'quickstart_graph.png' graph.write_png(output_file) print(f"Graph saved to {output_file}") except Exception as e: print(f"Error generating graph: {e}") print("Please ensure Graphviz is installed and its 'dot' executable is in your system's PATH.") # Clean up the generated file for demonstration purposes (optional) # if os.path.exists(output_file): # os.remove(output_file)
Debug
Known issues
breakingThe pydot-ng project is archived and read-only. It is no longer maintained. Users should migrate to the actively developed `pydot` library (PyPI: `pydot`, GitHub: `pydot/pydot`).
fix
Migrate your codebase to use the `pydot` library. Install with `pip install pydot` and update imports from `pydot_ng` to `pydot`.
affects: All versions (from 2.0.0 onwards, implicitly)
gotchaGraphviz (the underlying graph visualization software) must be installed separately on your system, and its executable files (e.g., `dot`, `neato`) must be accessible via your system's PATH environment variable. Pydot-ng (and pydot) will not work without a correctly configured Graphviz installation.
fix
Install Graphviz from its official website (graphviz.org) or via your system's package manager (e.g., `sudo apt-get install graphviz` on Debian/Ubuntu, `brew install graphviz` on macOS). Then, ensure the directory containing the Graphviz executables is added to your system's PATH.
affects: All versions of pydot-ng
deprecatedpydot-ng was a fork of pydot to support both Python 2 and 3. The original `pydot` project has since been updated to support Python 3+ and the `pydot-ng` repository explicitly directs users to `pydot`. Continued use of `pydot-ng` may lead to compatibility issues with newer Python versions or lack of bug fixes.
fix
Switch to using the `pydot` library, which is actively maintained and compatible with modern Python versions (e.g., Python 3.9+).
affects: All versions
gotchaOlder versions of pydot-ng might have issues locating Graphviz executables, particularly on Windows, sometimes looking for `.bat` files instead of `.exe`.
fix
Ensure Graphviz is properly installed and its `bin` directory is in the system PATH. For persistent issues, consider using the active `pydot` library, which likely has improved executable detection.
affects: <= 2.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pydot_ng'
The `pydot-ng` Python package is not installed in the active Python environment.
fix
Install the package using pip: `pip install pydot-ng`
pydot.InvocationException: GraphViz's executables not found
The Graphviz command-line tools (specifically the 'dot' executable) are not installed on your system or are not accessible via your system's PATH environment variable, which `pydot-ng` requires to render graphs.
fix
Install Graphviz from its official website (https://graphviz.org/download/) and ensure the installation directory containing 'dot.exe' (on Windows) or 'dot' (on Linux/macOS) is added to your system's PATH environment variable.
ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.
This generic error indicates that either the Python `pydot` (or `pydot-ng`) package is not installed, or more commonly, the underlying Graphviz command-line tools are missing or not properly configured in the system's PATH.
fix
First, ensure `pydot-ng` is installed (`pip install pydot-ng`). Then, install Graphviz (https://graphviz.org/download/) and add its 'bin' directory to your system's PATH. Restart your Python environment or IDE after modifying the PATH.
AttributeError: module 'pydot' has no attribute 'find_graphviz'
This error typically occurs when using an older codebase that expects the `find_graphviz` function, which was removed from newer versions of the `pydot` library. It can appear even when using `pydot-ng` if other parts of the code (like Keras visualization utilities) implicitly try to use `pydot` and encounter this API change.
fix
Update your code to no longer rely on `find_graphviz`, as modern `pydot` (and `pydot-ng`) automatically detect Graphviz if it's in the system's PATH. Alternatively, ensure Graphviz is correctly installed and its executables are in the PATH. If this error arises from an external library (e.g., Keras), check its documentation for compatibility with `pydot` versions. Some older solutions suggested `import pydot_ng as pydot` if facing this with `pydot`.
Upgrade
Version history
2.0.0latest on PyPI · released Oct 16, 2018
Audit
Dependencies
pyparsingrequiredRequired for parsing DOT files.
GraphvizrequiredSystem dependency: Required to render graphs into various output formats (e.g., PNG, SVG). Must be installed separately on the system and its executables (like 'dot') added to the system's PATH environment variable.
Agent activity
9 hits · last 30 days
node
8
Resources