ImportError: cannot import name 'escape' from 'cgi'
14,423
Solution 1
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.
Solution 2
cgi.escape()
has been removed in python 3.8. Quoting from here,
parse_qs, parse_qsl, and escape are removed from the cgi module. They are deprecated in Python 3.2 or older. They should be imported from the urllib.parse and html modules instead.
Since you are importing a third-party module, try using a lower python version.
Related videos on Youtube
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
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?
-
Nipun Sampath over 4 yearswhat python version do you use? Is it 3.8?
-
Admin over 4 yearsYes, it is 3.8.
-
-
Admin over 4 yearsThank you for your answer! But is there any other way that doesn't need a downgrade?
-
Nipun Sampath over 4 yearsI don't think so. You are getting the error because nltk has implemented
cgi.escape
in its code. Either you'll have to wait until they make nltk compatible with python 3.8 or do it yourself using nltk source. Also, maybe try opening an issue there?