pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible

后端 未结 14 1238
臣服心动
臣服心动 2020-11-28 01:15

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\" %         


        
相关标签:
14条回答
  • 2020-11-28 01:56

    There is a new package in the pip repo called pydot2 that functions correctly with pyparsing2. I couldn't downgrade my packages because matplotlib depends on the newer pyparsing package.

    Note: python2.7 from macports

    0 讨论(0)
  • 2020-11-28 01:56

    The solution was not to install pydot from somewhere, but "python-pydot" from official ubuntu repositories.

    0 讨论(0)
  • 2020-11-28 01:58

    I also met the problem and my pydot==1.0.28 while pyparsing==2.2.0. I fixed the problem by downloading the newest pydot 1.2.3(tar.gz)from google and then install it offline. When I updated the pydot in ubuntu 14.04, it said the pydot 1.0.28 is the newest version. Therefore I download from the google the 1.2.3 version.

    0 讨论(0)
  • 2020-11-28 02:01

    pydot used a private module variable (_noncomma) from pyparsing. The below diff fixes it to use for pyparsing 2.0.1:

    diff --git a/dot_parser.py b/dot_parser.py
    index dedd61a..138d152 100644
    --- a/dot_parser.py
    +++ b/dot_parser.py
    @@ -25,8 +25,9 @@ from pyparsing import __version__ as pyparsing_version
     from pyparsing import ( nestedExpr, Literal, CaselessLiteral, Word, Upcase, OneOrMore, ZeroOrMore,
         Forward, NotAny, delimitedList, oneOf, Group, Optional, Combine, alphas, nums,
         restOfLine, cStyleComment, nums, alphanums, printables, empty, quotedString,
    -    ParseException, ParseResults, CharsNotIn, _noncomma, dblQuotedString, QuotedString, ParserElement )
    +    ParseException, ParseResults, CharsNotIn, dblQuotedString, QuotedString, ParserElement )
    
    +_noncomma = "".join( [ c for c in printables if c != "," ] )
    
     class P_AttrList:
    
    0 讨论(0)
  • 2020-11-28 02:01

    On OSX Mavericks the following did the trick... I got the same error but at the bottom there was also a complaint that the graphviz executable was not present... I think the problem was i had installed graphviz prior to the other modules?

    brew uninstall graphviz
    brew install graphviz
    
    0 讨论(0)
  • 2020-11-28 02:03

    This worked for me (Mac OS X 10.9 with Python 2.7.10 on Anaconda):

    conda uninstall pydot
    

    Then,

    conda install pydot
    

    Pyparsing is then downgraded (from 2.x to 1.5.7) upon pydot's installation. Future Googlers: this allowed me to install and import Theano correctly.

    0 讨论(0)
提交回复
热议问题