“dot.exe” not found in path. Pydot on Python (Windows 7)

巧了我就是萌 提交于 2019-12-02 23:55:33
Ernest S Kirubakaran

I followed the instructions given in this blog.

Then I installed graphviz from here and added C:\Program Files (x86)\Graphviz2.38\bin to PATH.

Next I did:

conda install pydot-ng 

And finally in my notebook I added the two lines below.

import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'

Type conda install pydot graphviz in cmd, and then add the executables location directory C:\Anaconda3\pkgs\graphviz-2.38-hfd603c8_2\Library\bin\graphviz to your system path variable. That works!

Don't use the following command if you are on Python 3:

conda install pydot-ng 

This will take your installation to Python 2.7

Use instead

conda install graphviz
Gret

Using django-extensions to generate the model graph for your Django application, I did this and it worked:

pip install django-extensions
pip install pyparsing
pip install graphviz
pip install pydot
conda install graphviz

Add django-extensions to you INSTALLED_APPS and then add C:\Program Files\Anaconda3\pkgs\graphviz-2.38.0-4\Library\bin\graphviz to my system path variable. Then finally and normally:

python manage.py graph_models -a -g -o pic.png

Other solutions didn't work for me, and I figured out pydot tried to run a hardcoded dot.bat so I just created dot.bat wrapper nearby dot.exe and it worked:

@echo off
dot %*
ToxicGLaDOS

I was having trouble with this and found out that if you're using the Visual Studio Code integrated command line then you should make sure to restart Visual Studio Code (you might need to only restart the command line) otherwise the PATH changes won't take place...

In this kind of cases, when resources are not found by programs on your system, follow these quick steps:

  • Run a simple command prompt, type and execute the needed command (can be 'dot.exe')
  • If yes, your system is nicely configured and perhaps due to a hard configured way in your code, executables are not found (need a specific location for files to be found for instance: program check for C:\Program Files\Anaconda3\pkgs\graphviz and you put binaries in C:\Program Files\graphviz).
  • If no, you need to add it manually. In environment variable add the directory that contains the binaries (for instance 'my_location\graphviz\bin'). If you need it for whole users of the computer, put it in the system 'Path' (need to disconnect the users accounts to be considered), else in the user 'Path' (need to reopen the needed program). Then check it by re-opening a command prompt and typing the command.

If it's not working... you mistyped something =)

Some advices: Rapid Environment Editor is pretty cool for configuring windows environment variables ;)

Have a nice day!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!