5

I want to plot the decision tree of XGBoost. I followed the instructions from this webpage. I get this error:

 ImportError: You must install graphviz to plot tree

I tried to install graphviz_2.38.0-1~saucy_amd64.deb from graphviz. But I get this error:

 *Dependency is not satisfiable:libgraphviz4(>=2.18)*

So I did what is on this link

As it still does not work I downloaded the source code: graphviz-2.40.1.tar.gz But it still does not work. I thought that maybe I have installed it in the wrong path. So what does this mean: Make sure that the directory containing the dot executable is on your systems’ path?

I have installed it in /etc.

I use a virtual environment in conda

Any suggestions on what am I doing wrong?

EDIT:

I used pip install graphviz. now I get this error:

CalledProcessError: Command '['dot', '-Tpng']' returned non-zero exit status 1

Any idea?

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
Aizzaac
  • 3,146
  • 8
  • 29
  • 61
  • The original 15.xx packages are here http://old-releases.ubuntu.com/ubuntu/pool/main/g/graphviz/ .. You will probably need ` `libcgraph6_2.38.0-5build1_amd64.deb` and `graphviz_2.38.0-5build1_amd64.deb` . – Knud Larsen May 10 '17 at 16:16
  • Thanks. I will remove what I have installed and try the packages. – Aizzaac May 10 '17 at 16:38
  • 1
    All? dependencies, etc. : libcdt5, libcgraph6, libgd3, libgvc6, libgvpr2, libgraphviz-dev, libvpx3, libpathplan4 . ... One question: Why don't you install graphviz with **apt** ? – Knud Larsen May 10 '17 at 18:52
  • No. only graphviz_2.38.0-5build1_amd64.deb Do you mean sudo apt-get install graphviz? I already tested that. Same problem. There is even a post in stackoverflow about it. – Aizzaac May 10 '17 at 19:04

2 Answers2

10

As per this answer, you will need to install two conda packages:

  • graphviz, which only installs the graphviz system binaries.
  • python-graphviz, which installs the Python package for interfacing with graphviz.

So, install both packages with

conda install graphviz python-graphviz

and you should be ready to go.

albarji
  • 850
  • 14
  • 20
0

There are different packages that are called graphviz. Some of them refer to python packages others not. I think you are referring to the python version, but probably you installed the non-python version. If you refer to the python package, you can install it with pip (look here)

pip install graphviz
python -c "import graphviz"
# should give no errors

In addition you need the non-python version. You also can either install it via anaconda.

conda install graphviz
# this installs the non-python executables

Or you use the apt-get (I did not check whether this works):

apt-get install graphviz
Soerendip
  • 7,684
  • 15
  • 61
  • 128