pydot和graphviz错误:无法导入dot_parser,将无法加载点文件 [英] pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible

查看:201
本文介绍了pydot和graphviz错误:无法导入dot_parser,将无法加载点文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用pydot运行非常简单的代码

When I run a very simple code with pydot

import pydot
graph = pydot.Dot(graph_type='graph')

for i in range(3):

  edge = pydot.Edge("king", "lord%d" % i)
  graph.add_edge(edge)

vassal_num = 0
for i in range(3):
  for j in range(2):
    edge = pydot.Edge("lord%d" % i, "vassal%d" % vassal_num)
    graph.add_edge(edge)
    vassal_num += 1

graph.write_png('example1_graph.png')

它向我显示错误消息:

Couldn't import dot_parser, loading of dot files will not be possible.

我正在使用python 2.7.3

I'm using python 2.7.3

推荐答案

pydot >= 1.1的答案:

(上游)pydot的不兼容性已由 6dff94b3f1 修复,因此pydot >= 1.1pyparsing >= 1.5.7 兼容.

The incompatibility of (upstream) pydot has been fixed by 6dff94b3f1, and thus pydot >= 1.1 will be compatible with pyparsing >= 1.5.7.

适用于pydot <= 1.0.28的答案:

对于遇到此问题的其他人,这是由于pyparsing从1.x到2.x发行版的更改所致. 要使用pip安装pydot,请先安装较早版本的pyparsing:

For anyone else who comes across this, it is due to the changes in pyparsing from 1.x to the 2.x release. To install pydot using pip, first install the older version of pyparsing:

pip install pyparsing==1.5.7
pip install pydot==1.0.28

如果您未使用pip安装pyparsing,而是使用了setup.py,则请查看此

If you did not install pyparsing using pip, but instead used setup.py, then have a look at this solution to uninstall the package. Thanks @qtips.

这篇关于pydot和graphviz错误:无法导入dot_parser,将无法加载点文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆