pydot icon indicating copy to clipboard operation
pydot copied to clipboard

FileNotFoundError: [Errno 2] "dot" not found in path

Open sys-walker opened this issue 4 years ago • 7 comments

Description

I tried to use pydot to plot a decision tree but i got this error, i will provide the code used in order to reproduce that situation Main.py

$ /home/sys-walker/Documentos/PyCharmProjects/PlotDesicionTree/venv/bin/python /home/sys-walker/Documentos/PyCharmProjects/PlotDesicionTree/Main.py

Traceback (most recent call last):
  File "/home/sys-walker/Documentos/PyCharmProjects/PlotDesicionTree/Main.py", line 34, in <module>
    graph.write_png('example1_graph.png')
  File "/home/sys-walker/Documentos/PyCharmProjects/PlotDesicionTree/venv/lib/python3.8/site-packages/pydot.py", line 1743, in new_method
    self.write(
  File "/home/sys-walker/Documentos/PyCharmProjects/PlotDesicionTree/venv/lib/python3.8/site-packages/pydot.py", line 1828, in write
    s = self.create(prog, format, encoding=encoding)
  File "/home/sys-walker/Documentos/PyCharmProjects/PlotDesicionTree/venv/lib/python3.8/site-packages/pydot.py", line 1933, in create
    raise OSError(*args)
FileNotFoundError: [Errno 2] "dot" not found in path.
        ^

Time: 0.002s
sys-walker@(none):sys-walker>

Environment used

  • OS and python version information.
$  cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal


(venv) sys-walker@sys-walker:~/Documentos/PyCharmProjects/PlotDesicionTree$ python --version
Python 3.8.5

  • Pydot version used.
pydot version 1.4.2
  • Output of pip freeze command.
$ pip3 freeze
pkg-resources==0.0.0
pydot==1.4.2
pyparsing==2.4.7

sys-walker avatar Mar 02 '21 11:03 sys-walker

Do you have Graphviz installed? What is the output of running dot -V from the command line?

peternowee avatar Mar 02 '21 14:03 peternowee

It was this.I did have not install Graphviz, thanks a lot

sys-walker avatar Mar 02 '21 16:03 sys-walker

No problem, maybe we should see if we can make the error message more clear. Thanks, all the best!

peternowee avatar Mar 02 '21 18:03 peternowee

Should be solved as part of pydot/pydot#218. That PR is currently closed, but I hope to reopen it in the future.

peternowee avatar Mar 02 '21 18:03 peternowee

Hello,

Yes, it would be nice to have a clear error message. :As an addition, it would also be nice that the README states more clearly (that is: at the beginning) that graphviz needs to be installed. It's written in the Dependencies part, at the very end of this README. So this strange error comes once pydot is installed, and while doing a first trial. (as a wish: it could be automatically downloaded by pydot...)

Etienne

NB: in the meanwhile, please let this issue open! At least, we know what to do with this error. And now, I can generate graphviz schema from Python, which is nice! :)

etienne-sf avatar Apr 26 '21 16:04 etienne-sf

I faced the same error. I can't run dot -V. Please show me the way to fix it. Thank you very much.

My pip install:

pip freeze
graphviz==0.20.1
pydot==1.4.2
pyparsing==3.1.1

Update: I have to install by using sudo:

sudo apt-get install graphviz

However, if I do not have sudo permission, please help me to solve it.

mainguyenanhvu avatar Oct 18 '23 12:10 mainguyenanhvu

@sys-walker: Is the problem solved by using conda https://anaconda.org/conda-forge/graphviz?

mainguyenanhvu avatar Oct 26 '23 09:10 mainguyenanhvu