I downloaded Graphviz 2.38
MSI version and installed under folder C:\\Python34
, then I run pip install Graphviz
, everything went well.
On Ubuntu Linux this solved it for me:
pip install graphviz
sudo apt-get install graphviz
You could also try conda install -c conda-forge graphviz
instead of pip if using Anaconda.
OS Mojave 10.14., Python 3.6
Using pip install graphviz
had good feedback in terminal, but lead to this error when I tried to make a graph in a Jupyter notebook. I then ran brew install graphviz
, which gave an error in terminal. Then I ran conda install graphviz
and the graph worked.
From @Leighton's comment: pip only gets path problem same as yours and conda only gets import error.
Add graphviz to the System Path
Ex: C:\Users\AppData\Local\Continuum\anaconda3\Library\bin\graphviz
Try conda install graphviz
. I had the same problem, I resolved it by mentioned command in MacOS.
After you've installed the package (link if you haven't), add the path to dot.exe as a new system variable.
Default path is:
C:\Program Files (x86)\Graphviz2.38\bin\dot.exe
For Linux users who don't have root access and hence can't use sudo
command as suggested in other answers...
First, activate your conda virtual-environment (if you want to use one) by:
source activate virtual-env-name
Then install graphviz, even if you have already done it using pip:
conda install graphviz
then copy the result of the following command:
whereis dot
In my case, its output is:
/home/nader/anaconda2/bin/dot
and add it to your PATH variable. Just run the command below
nano ~/.bashrc
and add these lines to the end of the opened file:
PATH="/home/username/anaconda2/bin/dot:$PATH"
export PATH
now press Ctrl+O and then Ctrl+X to save and exit.
Problem should be solved by now.
Pycharm users, please note: Pycharm does not always see the PATH variable the same as your terminal. This solution does not work for Pycharm, and maybe other IDEs. But you can fix this by adding this line of code:
os.environ["PATH"] += os.pathsep + '/home/nader/anaconda2/bin'
to your python program. Do not forget to
import os
first :)
Edit: If you don't want to use conda, you can still install graphviz from here without any root permissions and add the bin folder to your PATH variable. I didn't test this.