Install PyGraphViz

PyGraphViz Python libraries are used to plot causal inference networks.

If you try to install PyGraphViz as a standard library, it fails due to dependency errors.

PyGraphViz has the following dependencies:

  • python3-dev
  • graphviz
  • libgraphviz-dev
  • pkg-config

Install via notebook

  1. Install the dependencies with apt-get.

    sudo apt-get install -y python3-dev graphviz libgraphviz-dev pkg-config
    
  2. After the dependencies are installed, use pip to install PyGraphViz.

    pip install pygraphviz
    

Install via init script

  1. Create the init script.

    dbutils.fs.put("dbfs:/databricks/<init-script-folder>/install-pygraphviz.sh",
    """
    #!/bin/bash
    #install dependent packages
    sudo apt-get install -y python3-dev graphviz libgraphviz-dev pkg-config
    pip install pygraphviz""", True)
    
  2. Install the init script that you just created as a cluster-scoped init script.

    You will need the full path to the location of the script (dbfs:/databricks/<init-script-folder>/install-pygraphviz.sh).

  3. Restart the cluster after you have installed the init script.