在windows平台,如果使用pycharm报错FileNotFoundError:“dot.exe” not found in path,表明你的dot.exe不在指定路径中。
按照原代码的注释说明,你可以使用两种方法来解决:
1,将dot.exe所在的bin加入PATH变量;
2,直接在代码中将dot改为dot.exe。
但是,你这么做了或者两个都做了,发现报错仍然跟以前一样,这是为什么呢?
没有人告诉过你,当你更改了这些系统参数以后,要重启电脑。
是的,你没有看错,按照注释的说明操作后,重启电脑即可。
此方法适用于一系列需要更改环境变量的操作。。。
附上pydot中的注释原文。
On Windows, these have the notorious “.exe” extension that, only for the above strings, will be added automatically.
The $PATH
is inherited from os.env['PATH']
and passed to subprocess.Popen
using the env
argument.
If you haven’t added GraphViz to your $PATH
on Windows, then you may want to give the absolute path to theexecutable (for example, to dot.exe
) in prog
.
再附一张来自networkx的官方examples中的精美circular tree。