importtreepycharmnltk

ImportError: cannot import name 'escape' from 'cgi'


I'm getting the error message "ImportError: cannot import name 'escape' from 'cgi'" when I try to use following code in pycharm:

import nltk 
parser = nltk.ChartParser(grammar, trace=0)

for tree in parser.parse(sent):
    print(tree)
    tree.pretty_print(unicodelines=True)

What should I do to correct it?


Solution

  • I have updated the supervisor package version into: supervisor==4.1.0

    https://pypi.org/project/supervisor/4.1.0/

    [Fixed a Python 3.8 compatibility issue caused by the removal of cgi.escape(). Patch by Mattia Procopio.]

    problem solved.