【发布时间】:2023-03-03 21:54:01
【问题描述】:
问题:如何在 macOS 的 Spyder (Anaconda) 中正确执行 Graphviz 中的 'dot'?
背景:我知道这个话题已经在其他帖子中讨论过:
- How to use Graphviz with Anaconda/Spyder?
- (Python) ValueError: Program dot not found in path
- Exception: “dot” not found in path in python on mac
但是我已经尝试了这些帖子的所有建议,但我仍然收到错误:
Exception: “dot” not found in path in python on mac
FileNotFoundError: [Errno 2] No such file or directory: 'dot'
ExecutableNotFound: failed to execute ['dot', '-Kdot', '-Tpdf', '-O', 'FileName'], make sure the Graphviz executables are on your systems' PATH
我已经安装了 Graphviz,如下所示,dot 正在工作:
上面可以通过输入看到:
dot -V
它返回我安装的版本。以及打字时:
which dot
它返回文件的位置(即 /usr/local/bin)。我已经用这条路径尝试了几件事。
- 将其添加到 Spyder 中的路径中:
- 我在主系统PATH中添加了:
- 我什至在 Python 中运行了一个脚本,试图从代码中添加路径(我尝试过在路径末尾添加和不添加“点”):
以上解决方案都不适合我。如果有人能给我一些见解来解决这个问题,我将不胜感激。
例如,您可以尝试下面的代码,这是给我错误的代码 (source):
import graphviz
dot = graphviz.Digraph(comment='The Round Table')
dot.node('A', 'King Arthur')
dot.node('B', 'Sir Bedevere the Wise')
dot.node('L', 'Sir Lancelot the Brave')
dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')
dot.render('FileName', view=True)
【问题讨论】:
标签: python macos spyder graphviz dot