pythonpython-3.xflaskflask-sqlalchemyflask-wtforms

Python can't import installed module


I'm trying to run an legacy app with flask. Among all errors, i've encountered a "ModuleNotFoundError: No module named 'wtforms.ext' "

So, as with others ModuleNotFoundError, i installed the 'wtforms' module with 'python3 -m pip install wtf' but did not worked.

I've also tried: 'flask_wtf', 'wtforms.ext', 'WTForms', 'flask-wtf', 'Flask-WTF', 'wtf' and 'wtf --use-pep517'. None of them work

enter image description here

Does anyone got a hint?

Thanks


Solution

  • The wtforms.ext module you’re trying to import has been deprecated (2.3.1 wtform changelogs) in recent versions of WTForms.

    Solution:

    E.g. if using wtforms.ext.sqlalchemy (for example, oyu may be using something else), replace is with WTForms-Alchemy:

    python3 -m pip install WTForms-Alchemy
    

    Fix imports:

    # Old import
    from wtforms.ext.sqlalchemy.fields import QuerySelectField
    
    # New import
    from wtforms_alchemy import QuerySelectField
    

    Review the linked documentation to find any specific replacements you might have in your code or setup.