Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sys-walker opened this issue Mar 2, 2021 · 14 comments
Closed

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

sys-walker opened this issue Mar 2, 2021 · 14 comments

Comments

@sys-walker
Copy link

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
@peternowee
Copy link
Member

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

@sys-walker
Copy link
Author

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

@peternowee
Copy link
Member

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

@peternowee
Copy link
Member

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

@etienne-sf
Copy link

etienne-sf commented Apr 26, 2021

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! :)

@mainguyenanhvu
Copy link

mainguyenanhvu commented Oct 18, 2023

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
Copy link

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

@lkk7
Copy link
Member

lkk7 commented Jun 7, 2024

The issue is fixed by installing graphviz in any way possible on your system: https://graphviz.org/ and making sure it's on your PATH when the script using pydot is running.
I'll try to change the error message to make it clearer.

Closing because of inactivity.
Feel free to tag me if you encounter any more problems!

@lkk7 lkk7 closed this as completed Jun 7, 2024
@mainguyenanhvu
Copy link

@lkk7 how can I find pydot PATH?

@lkk7
Copy link
Member

lkk7 commented Jun 8, 2024

Hi @mainguyenanhvu,

Do you have graphiz (dot) already installed?
If you can run a dot -V command, it's already in your PATH.
If not, you have to add it to your PATH. The way of doing that depends on your operating system.

@mainguyenanhvu
Copy link

@lkk7 I do not see that PATH and not found dot when running dot -V. My OS is Ubuntu 22.04 LTS. Please help me.

@lkk7
Copy link
Member

lkk7 commented Jun 8, 2024

@mainguyenanhvu

Try installing graphviz:
sudo apt install graphviz

This should fix the problem.

If you still have problems with sudo like you said earlier, then you have to solve the issue on your own. Is this your own system/computer? If not, you'll have to ask the admin to install this for you. If this is your computer and system, then you should be able to use sudo.

@mainguyenanhvu
Copy link

@lkk7 Thank you for your support. I understand that there is no way except using sudo to overcome this problem.

@lkk7
Copy link
Member

lkk7 commented Jun 10, 2024

@mainguyenanhvu well, maybe you can install it without sudo, just like this: apt install graphviz.
But I can't help much more without knowledge about your specific system and environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants