Missing `graphviz` - please run `conda install fastbook`

Hi! I started to use the updated fastai library (former v2) and trying to run the course-v4/nbs/01_intro.ipynb notebook. Something seems to be wrong with fastbook and graphviz.

On “import fastbook” the error about missing graphviz is fired. The suggestion to install fastbook does not help, because is does not lead to installing graphviz. So it looks like there is not such a dependency. (BTW when trying now, a “PackagesNotFoundError” rises when trying a “conda install fastbook”). I considered the option to install graphviz directly, but that leads to a big “Package Plan” including quite a few downgrades. I don’t feel comfortable with that.

I tried different installation methods (pip, conda and used a ready to use docker container) and in every case I ran into the same situation.

Any suggestions?

Thanks,
Herald

5 Likes

I got similar problem also, I was able to install python graphviz package but it doesn’t work until i install graphviz using “sudo apt install graphviz” on Ubuntu.

1 Like

Thanks for your answer. And I am glad it worked for you. I also was using an Ubuntu based system.

However, in my case, the graphviz package was already installed:

$ dpkg --list | fgrep graphviz
ii  graphviz                                   2.42.2-3build2                        amd64        rich set of graph drawing tools

But the grahviz python module is missing (I checked with conda list | fgrep graphviz).

Importing fastbook in python raises this error:

$ echo "import fastbook" | python3
/home/herald/anaconda3/envs/fastai/lib/python3.8/site-packages/fastbook/__init__.py:21: UserWarning: Missing `graphviz` - please run `conda install fastbook`
  except ModuleNotFoundError: warn("Missing `graphviz` - please run `conda install fastbook`")

When I run conda install fastbook the result is a PackagesNotFoundError. When I run a conda install -c fastai fastbook, it was able to find and install the module, but still same error.

Finally I fixed it by removing and recreating the conda environment and installed fastai again with conda install -c fastai -c pytorch fastai. After that the fastbook module was not installed and I installed it with conda install -c fastai fastbook

$ conda install -c fastai fastbook
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/herald/anaconda3/envs/fastai

  added / updated specs:
    - fastbook


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cairo-1.14.12              |       h8948797_3         1.3 MB
    cffi-1.14.0                |   py38h2e261b9_0         228 KB
    fastbook-0.0.8             |     pyh39e3cac_0          18 KB  fastai
    fastscript-1.0.0           |     pyh39e3cac_0          15 KB  fastai
    fribidi-1.0.10             |       h7b6447c_0         115 KB
    glib-2.63.1                |       h5a9c865_0         3.4 MB
    graphite2-1.3.14           |       h23475e2_0         102 KB
    harfbuzz-1.8.8             |       hffaf4a1_0         863 KB
    libffi-3.2.1               |       hd88cf55_4          43 KB
    nbdev-1.0.1                |     pyh39e3cac_0          51 KB  fastai
    pango-1.42.4               |       h049681c_0         528 KB
    pixman-0.40.0              |       h7b6447c_0         628 KB
    python-3.8.2               |       hcf32534_0        57.8 MB
    python-graphviz-0.14       |             py_0          25 KB
    ------------------------------------------------------------
                                           Total:        65.1 MB

The following NEW packages will be INSTALLED:

  cairo              pkgs/main/linux-64::cairo-1.14.12-h8948797_3
  fastbook           fastai/noarch::fastbook-0.0.8-pyh39e3cac_0
  fastscript         fastai/noarch::fastscript-1.0.0-pyh39e3cac_0
  fribidi            pkgs/main/linux-64::fribidi-1.0.10-h7b6447c_0
  graphite2          pkgs/main/linux-64::graphite2-1.3.14-h23475e2_0
  graphviz           pkgs/main/linux-64::graphviz-2.40.1-h21bd128_2
  harfbuzz           pkgs/main/linux-64::harfbuzz-1.8.8-hffaf4a1_0
  nbdev              fastai/noarch::nbdev-1.0.1-pyh39e3cac_0
  pango              pkgs/main/linux-64::pango-1.42.4-h049681c_0
  pixman             pkgs/main/linux-64::pixman-0.40.0-h7b6447c_0
  python-graphviz    pkgs/main/noarch::python-graphviz-0.14-py_0

The following packages will be DOWNGRADED:

  cffi                                1.14.1-py38he30daa8_0 --> 1.14.0-py38h2e261b9_0
  glib                                    2.65.0-h3eb4bd4_0 --> 2.63.1-h5a9c865_0
  libffi                                     3.3-he6710b0_2 --> 3.2.1-hd88cf55_4
  python                                   3.8.5-hcff3b4d_0 --> 3.8.2-hcf32534_0


Proceed ([y]/n)?

After that I installed jupyter notebook of course. And then the environment was operational again.

On another system (Fedora based) I installed fastai using pip. Initially I had the same problem, but removing all existing python modules and doing a pip install --user fastai followed by pip install --user graphviz gave me back a workable environment.

Cheers,
Herald

13 Likes

that helped a great deal. thank you!

now running fastaiV2 on my ubuntu20.04+GPU at home :wink:

I am on amazon aws. I cant get past

NameError Traceback (most recent call last)
in
4 #alt Pipeline inputs, program, results
5 gv(’’‘program[shape=box3d width=1 height=0.7]
----> 6 inputs->program->results’’’)

~/anaconda3/envs/python3/lib/python3.6/site-packages/fastbook/init.py in gv(s)
42 if IN_COLAB: return setup_colab()
43
—> 44 def gv(s): return graphviz.Source(‘digraph G{ rankdir=“LR”’ + s + ‘; }’)
45
46 def get_image_files_sorted(path, recurse=True, folders=None):

NameError: name ‘graphviz’ is not defined

How does one remove and reinstall conda environment?

sh-4.2$ conda env list

conda environments:

base /home/ec2-user/anaconda3
JupyterSystemEnv * /home/ec2-user/anaconda3/envs/JupyterSystemEnv
R /home/ec2-user/anaconda3/envs/R
amazonei_mxnet_p27 /home/ec2-user/anaconda3/envs/amazonei_mxnet_p27
amazonei_mxnet_p36 /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36
amazonei_tensorflow2_p27 /home/ec2-user/anaconda3/envs/amazonei_tensorflow2_p27
amazonei_tensorflow2_p36 /home/ec2-user/anaconda3/envs/amazonei_tensorflow2_p36
amazonei_tensorflow_p27 /home/ec2-user/anaconda3/envs/amazonei_tensorflow_p27
amazonei_tensorflow_p36 /home/ec2-user/anaconda3/envs/amazonei_tensorflow_p36
chainer_p27 /home/ec2-user/anaconda3/envs/chainer_p27
chainer_p36 /home/ec2-user/anaconda3/envs/chainer_p36
mxnet_p27 /home/ec2-user/anaconda3/envs/mxnet_p27
mxnet_p36 /home/ec2-user/anaconda3/envs/mxnet_p36
python2 /home/ec2-user/anaconda3/envs/python2
python3 /home/ec2-user/anaconda3/envs/python3
pytorch_latest_p36 /home/ec2-user/anaconda3/envs/pytorch_latest_p36
pytorch_p27 /home/ec2-user/anaconda3/envs/pytorch_p27
pytorch_p36 /home/ec2-user/anaconda3/envs/pytorch_p36
tensorflow2_p36 /home/ec2-user/anaconda3/envs/tensorflow2_p36
tensorflow_p27 /home/ec2-user/anaconda3/envs/tensorflow_p27
tensorflow_p36 /home/ec2-user/anaconda3/envs/tensorflow_p36

try running

conda install python-graphviz

2 Likes

No, That does not make a difference, I’m afraid.

Hi there. I’m having the same issue trying to run the first notebooks from my Ubuntu machine at home. But with me, it seems a little bit more awkward. When I try to instal through conda, I receive the message bellow:

Package python conflicts for:
defaults|defaults/linux-64::python==3.7.9=h7579374_0
defaults/linux-64::python==3.7.9=h7579374_0The following specifications were found to be incompatible with your system:

  • feature:/linux-64::__cuda==10.2=0

Your installed version is: 10.2

But my installed version of Cuda is 10.1.
$ nvcc --version
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

$ conda list | grep cud
cudatoolkit 10.1.243 h6bb024c_0 anaconda
cudnn 7.6.5 cuda10.1_0 anaconda
pytorch 1.6.0 py3.7_cuda10.1.243_cudnn7.6.3_0 pytorch

I followed the step suggested by yelwinsoe, it has been installed, but makes no difference at all. Then, I followed the steps suggested by heraldb and found the same problem: when I run from the notebook the pip install comand and try to import fastbook, I get the message that graphviz is missing. Tried also conda install python-graphs, as long as conda install -c conda-forge python-graphviz and conda install -c anaconda graphviz. To all of these commands I get the same cuda error.

Can anyone give a hand? Thanks a lot.

I can second this fix. Works for me now. Running Ubuntu 18.04.

This worked for me in AzureML. Thank you.

1 Like

Had the same problem after using the guide for Google Cloud https://course.fast.ai/start_gcp

The above solution by @heraldb didn’t work for me as it tried to downgrade to fastai 1.0 for me.

I ended up making it work by creating a new conda environment using fastbook’s environment.yml and then setting jupyter to use that environment. Steps I took:

cd ~/fastbook
conda env create --file environment.yml
conda activate fastbook
python -m ipykernel install --user --name=fastbook
pip install -Uqq fastbook

Then in Google Cloud I clicked on the + in the top right, opened a new Launcher, and selected the “fastbook” Notebook. Everything worked once I was running notebooks through this environment.

Make sure the top right “Kernel” selection says fastbook like in the screenshot:

3 Likes

I had this issue, you need to run conda install -c fastai fastbook and conda will find/install the packages which includes graphviz.

2 Likes

Anyone using GCP have a solution? I can’t seem to get graphviz to load?

This worked, running this in the notebook pip install graphviz. Thanks to @immarried post here Seeking help - No module named 'graphviz'

1 Like

Thanks - pip install graphviz worked for GCP

Run this jupyter cell:

!pip install -Uqq fastbook
!pip install --user graphviz

This worked for me (and I think it was has worked for most in this thread).

Thanks a lot. Installing graphviz using ‘conda install python-graphviz’ worked on my mac.

Had a similar issue. The cuda version you externally installed is not required/doesn’t matter. check the version of cudatoolkit (conda list cudatoolkit). This will get you 10.2 I think.

Looks like you have a cuda mismatch with pytorch and/or python.

Remove pytorch cuda and torchvision and reinstall it together as shown below:

conda remove pytorch torchvision cudatoolkit

conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1.168 -c pytorch

For fast ai2, based on my NVIDIA driver (430) I chose the cuda 10.1, I needed based on table 1.

Does this help?

P.S
I didn’t need to install cuda externally. pytorch “gets compiled” and delivered with it’s own CUDA via conda (look for cudatoolkit)

conda install graphviz also is enough and only modifies your current environment in which you are using it.

it does work thanks