fastbook流程图显示不正常

6 篇文章 0 订阅
5 篇文章 0 订阅

背景:

             在使用jupyter阅读fastbook时一些用代码生成的图不能正常显示,在执行相应代码时报错如下:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
~/.local/lib/python3.6/site-packages/graphviz/backend.py in run(cmd, input, capture_output, check, encoding, quiet, **kwargs)
    163     try:
--> 164         proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs)
    165     except OSError as e:

/usr/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    728                                 errread, errwrite,
--> 729                                 restore_signals, start_new_session)
    730         except:

/usr/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1363                             err_msg += ': ' + repr(err_filename)
-> 1364                     raise child_exception_type(errno_num, err_msg, err_filename)
   1365                 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'dot': 'dot'

During handling of the above exception, another exception occurred:

ExecutableNotFound                        Traceback (most recent call last)
~/.local/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    343             method = get_real_method(obj, self.print_method)
    344             if method is not None:
--> 345                 return method()
    346             return None
    347         else:

~/.local/lib/python3.6/site-packages/graphviz/files.py in _repr_svg_(self)
    142 
    143     def _repr_svg_(self):
--> 144         return self.pipe(format='svg').decode(self._encoding)
    145 
    146     def pipe(self, format=None, renderer=None, formatter=None, quiet=False):

~/.local/lib/python3.6/site-packages/graphviz/files.py in pipe(self, format, renderer, formatter, quiet)
    169         out = backend.pipe(self._engine, format, data,
    170                            renderer=renderer, formatter=formatter,
--> 171                            quiet=quiet)
    172 
    173         return out

~/.local/lib/python3.6/site-packages/graphviz/backend.py in pipe(engine, format, data, renderer, formatter, quiet)
    246     """
    247     cmd, _ = command(engine, format, None, renderer, formatter)
--> 248     out, _ = run(cmd, input=data, capture_output=True, check=True, quiet=quiet)
    249     return out
    250 

~/.local/lib/python3.6/site-packages/graphviz/backend.py in run(cmd, input, capture_output, check, encoding, quiet, **kwargs)
    165     except OSError as e:
    166         if e.errno == errno.ENOENT:
--> 167             raise ExecutableNotFound(cmd)
    168         else:
    169             raise

ExecutableNotFound: failed to execute ['dot', '-Kdot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

解决方法: 

           安装graphviz,如在ubuntu上可以通过命令行执行:

 sudo apt-get install graphviz

解决过程:

从错误提示信息看到:

ExecutableNotFound: failed to execute ['dot', '-Kdot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

可以判断是在调用程序Graphviz时找不到这个程序的可执行文件,有可能没有安装。查找ubuntu安装Graphviz方法,并尝试安装后问题解决.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个不安分的程序员

祝您财源广进

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值