. Advertisement .
..3..
. Advertisement .
..4..
The error: “ModuleNotFoundError: No module named ‘wtforms.compat’” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
When Does The Error: “ModuleNotFoundError: No module named ‘wtforms.compat’” Happen?
When attempting to import text type from the wtforms.compat package, you might experiene the following issue.
ModuleNotFoundError: No module named 'wtforms.compat'
How To Solve The “ModuleNotFoundError: No module named ‘wtforms.compat’” Issue
Approach 1: Downgrade wtforms
If you’re having trouble with the above error, all you have to do is downgrade wtforms to version 2.2. Simply type:
pip install wtforms==2.2
or
pip install wtforms==2.3.3
And that will be the end of your issue.
Approach 2: For Python <3.6
If you utilize Python <3.6, you’ll need to use wtforms<=2.3.3 to get around this problem. This is the second method for “ModuleNotFoundError: No module named ‘wtforms.compat’” that we want to suggest you. After you do that, your error will be solved.
Approach 3: Use str to interact with wtforms
Because compat.py was only used for adding more details, compat.py was totally removed once Python 3.6 support was discontinued. Text type and string types are essentially aliases, so if you are using Python >= 3.6, you can also use str
to interact with the most recent wtforms
instead of string_types
and text_type
as the following:
if sys.version_info[0] >= 3:
text_type = str
string_types = (str,)
izip = zip
And you should not need the imports anymore.
This is also a great method for solving the “ModuleNotFoundError: No module named ‘wtforms.compat’” issue. Let’s it to get your desired result.
Conclusion
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “ModuleNotFoundError: No module named ‘wtforms.compat’” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Read more
→ Tips On Solving The Error: “ModuleNotFoundError: No module named ‘jsonschema.compat’”
Leave a comment