1

I tried to use the flask_wtf in my python2 script but i get this error

    File "bartender.py", line 16, in <module>
    from flask_wtf import FlaskForm
  File "/usr/local/lib/python2.7/dist-packages/flask_wtf/__init__.py", line 1, in <module>
    from .csrf import CSRFProtect, CsrfProtect
  File "/usr/local/lib/python2.7/dist-packages/flask_wtf/csrf.py", line 220
    dest = f'{view.__module__}.{view.__name__}'
                                              ^
SyntaxError: invalid syntax

here is my import line

from flask import Flask, render_template, jsonify, request, redirect, url_for
from multiprocessing import Process
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField
from wtforms.validators import NumberRange, Length

I know python3 is out and we should use this but this is a very ols script from me and i tried to extend it and I also do a python3 portation :)

4
  • 2
    That's an f string and isn't available in Python 2. Commented Jun 7, 2021 at 17:26
  • and how to avoid this? Commented Jun 7, 2021 at 17:47
  • 1
    Update to python 3 or pin your dependencies to a version that doesn't need python 3 Commented Jun 7, 2021 at 17:58
  • how do I downgrade to flask_wtf for python2? Commented Jun 7, 2021 at 18:10

1 Answer 1

1

This should work

pip install flask-wtf==0.14.3
Sign up to request clarification or add additional context in comments.

1 Comment

Please explain why this would help. edit the post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.