How to install pydot and graphviz?

python-pydot and graphviz are in the default Ubuntu repositories in all currently supported versions of Ubuntu. In all currently supported versions of Ubuntu, open the terminal and type:

sudo apt install python-pydot python-pydot-ng graphviz # python-pydot-ng isn't in the 14.04 repos

This flowchart was created with graphviz in Ubuntu. Because graphviz uses the built-in dot programming language which is included in the graphviz package, the source code of the linked flowchart is editable in any text editor even if python-pydot is not installed.

I don't know why you would want to install pydot with pip when you can get it from the Ubuntu repositories, but to answer your question I tried installing pydot anyway in a Python virtual environment with pip3 install pydot and it worked, so it is possible that you need to update pip to the latest version with sudo -H pip3 install --upgrade pip. I used pip3 instead of pip because you wrote in your question that you are using Python 3.5.


From this answer on "Installing pydot and graphviz packages in Anaconda environment"

I had the same issue and solved it by (order is important):

  1. Installing graphviz, simply via sudo apt-get install graphviz
  2. Installing graphviz for Python via conda sudo ~/anaconda2/bin/conda install graphviz
  3. Finally, by installing pydot using conda sudo ~/anaconda2/bin/conda install pydot

This answer is overdue but this post helped me (together with this one that mentions the installation order), so hopefully this answer will help someone else. I'm using Ubuntu 14.04 and Python 2.7.

P.S. apparently, there could be some issues with step 1 of the above algorithm, this post mentions how to fix them.


Because you use python 3, the right command would be pip3 install pydot graphviz. You can install pip3 using sudo apt install python3-pip.