0

I am trying to run a sample flask app, which is using wtforms and wtf_flask libraries. I have requirements.txt file which i installed in my venv, which contains:

flask-oidc==1.4.0

Flask-WTF==0.15.1

WTForms==2.3.3

among others.

I have app.py that has import lines as below:

from flask_wtf import FlaskForm

from wtforms import SubmitField

Now, when i run "flask run" from command-line, i get error **"Error: While importing 'app', an ImportError was raised."**I added a bunch of print-statements in between different import-statements, so i know that it gets stuck at "from flask_wtf import FlaskForm". When instead i do: "python3 app.py" OR "python3 -m flask run" - everything runs.

Could someone please explain what the subtle difference is that is causing import errors in first scenario, but not in 2nd and 3rd. Thank you so much in advance!

JustLearning
  • 180
  • 2
  • 12
  • The same as with `pip`: `flask` will run whichever version of the `flask` program wrapper is found first on the path, while `python -m flask` will run whichever version *of Python* is found first on the path, and then have that Python installation use its corresponding version of Flask. – Karl Knechtel May 04 '22 at 16:09
  • "i get error" Please read https://meta.stackoverflow.com/questions/359146, and show *complete* error tracebacks when asking a question. Copy and paste, starting from the line that says `Traceback (most recent call last):`, and format like code. – Karl Knechtel May 04 '22 at 16:10

0 Answers0