Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named wtforms.compat

Tags:

python

wtforms

While we are trying to execute with python 3.6.8 version getting below module error

from wtforms.compat import string_types, text_type
ModuleNotFoundError: No module named 'wtforms.compat'

when i tried installing or upgrading wtforms still it shows the same error

Can any one pls suggest

like image 832
Ravi Avatar asked Nov 08 '21 06:11

Ravi


Video Answer


1 Answers

Noticed this error today while running our Airflow 1.10.12 builds:

from wtforms.compat import text_type
ModuleNotFoundError: No module named 'wtforms.compat'

Apparently, the issue has to do with the latest version of wtforms released yesterday (3.0.0). We managed to get around it by pinning it to the previous version: wtforms==2.3.3.

Editing just to add more information: compat.py was completely removed once support for Python < 3.6 was dropped (see PR). If you are running Python >= 3.6, you can also work with the latest wtforms by simply using str instead of text_type and string_types, since those were just aliases:

if sys.version_info[0] >= 3:
    text_type = str
    string_types = (str,)
    izip = zip

And the imports should not be needed anymore.

If running Python < 3.6, you may need to stick with wtforms<=2.3.3.

like image 51
Tomas Farias Avatar answered Oct 15 '22 20:10

Tomas Farias