Installing Graphviz on Windows 10 with Anaconda3 and Using it in Jupyter Notebook/Python3

Installing Graphviz on Windows 10 with Anaconda3 and Using it in Jupyter Notebook/Python3
Graphviz is an open-source graph visualization software that provides a simple way to create, represent and manipulate structured information in the form of graphs. It’s a powerful tool for data scientists who need to visualize complex data structures and relationships. In this blog post, we’ll guide you through the process of installing Graphviz on Windows 10 using Anaconda3, and then show you how to use it in a Jupyter Notebook with Python3.
Step 1: Installing Anaconda3
Before we can install Graphviz, we need to ensure that Anaconda3 is installed on your Windows 10 machine. Anaconda is a free and open-source distribution of Python and R for scientific computing. It simplifies package management and deployment, making it easier to install and manage software dependencies.
To download Anaconda3, visit the Anaconda Distribution page and select the Windows version. Follow the instructions to install it on your system.
Step 2: Installing Graphviz
Once Anaconda3 is installed, we can proceed to install Graphviz. Open the Anaconda Prompt from the start menu and type the following command:
conda install -c anaconda graphviz
This command tells Anaconda to install the Graphviz package from the Anaconda channel. Wait for the process to complete.
Step 3: Installing Python-Graphviz
Python-Graphviz is a Python interface to the Graphviz graph layout and visualization package. To install it, use the following command in the Anaconda Prompt:
conda install -c anaconda python-graphviz
Step 4: Verifying the Installation
To verify that Graphviz is installed correctly, you can run the following command in the Anaconda Prompt:
python -c "import graphviz; print(graphviz.__version__)"
If the installation was successful, this command will print the version of Graphviz installed on your system.
Step 5: Using Graphviz in Jupyter Notebook
Now that Graphviz is installed, we can start using it in a Jupyter Notebook. First, launch Jupyter Notebook by typing jupyter notebook
in the Anaconda Prompt.
In your Jupyter Notebook, you can import the Graphviz module with the following command:
import graphviz
To create a simple graph, you can use the Digraph
class, which creates a directed graph:
dot = graphviz.Digraph()
dot.node('A', 'King Arthur')
dot.node('B', 'Sir Bedevere the Wise')
dot.node('L', 'Sir Lancelot the Brave')
dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')
dot
This will create a graph with three nodes (King Arthur, Sir Bedevere the Wise, and Sir Lancelot the Brave) and three edges (from King Arthur to the other two, and from Sir Bedevere the Wise to Sir Lancelot the Brave).
Conclusion
Graphviz is a powerful tool for visualizing complex data structures and relationships. With Anaconda3, installing and using Graphviz on Windows 10 becomes a straightforward process. We hope this guide has helped you get started with Graphviz in Jupyter Notebook and Python3. Happy graphing!
Keywords: Graphviz, Anaconda3, Jupyter Notebook, Python3, Data Visualization, Windows 10, Data Science, Graphs, Installation Guide
About Saturn Cloud
Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.