Forums

ModuleNotFoundError: No module named 'flask_wtf'

Hello. As you can see below, I can't import flask_wtf and it isn't in my site-packages folder. I have tried installing and upgrading it, with no success, despite of the fact I always get the return stating "Requirement already up-to-date" or "Requirement already satisfied".

ERROR LOG:

Error running WSGI application
2019-01-11 00:31:52,426: ModuleNotFoundError: No module named 'flask_wtf'
2019-01-11 00:31:52,426:   File "/var/www/juliosouto_pythonanywhere_com_wsgi.py", line 16, in <module>
2019-01-11 00:31:52,426:     from flask_app import app as application  # noqa
2019-01-11 00:31:52,426: 
2019-01-11 00:31:52,427:   File "/home/juliosouto/mysite/flask_app.py", line 9, in <module>
2019-01-11 00:31:52,427:     from flask_wtf import Form #FlaskForm, TextField, TextAreaField, SubmitField, validators, ValidationError

FLASK:

I have tried these 2 different ways:

from flask.ext.wtf import Form, TextField, TextAreaField, SubmitField, validators, ValidationError

from flask_wtf import Form, FlaskForm, TextField, TextAreaField, SubmitField, validators, ValidationError

What can I do to make it work?

[edit by admin: formatting]

How are you installing it? It looks like your website is configured to use a virtualenv, so you need to start a bash console inside that virtualenv (there's a shortcut link to do that on the "Web" page) and then pip install from there.

I installed using a bash console. command "pip3 install --user flask_wtf". Also using "Flask_WTF". But in both cases the console said it was already satisfied. Also, I installed marshmallow using the same command. It was installed in the site-packages folder, but I cannot import it either.

Just as complementary: flask_wtf seemed it was installed already (before I try to install it), but it is not in the site-packages folder. On the other hand, marshmallow wasn't previously installed. It was installed by me and it is in the site-packages folder. But none of them can be imported on Flask.

Yes, if you try to install using the "--user" flag in a normal Bash console then it will say that flask_wtf is already installed because we have a site-wide installation of that package. And if you try to install something that is not already installed, it will put it in the appropriate place under .local.

But your website is using a virtualenv. A virtualenv is a completely different set of installed packages. Packages that you install using "--user" will not go into the virtualenv. In order to install into it, you need to activate the virtualenv and then use pip install without the "--user" flag. The easiest way to do this is:

  • Go to the "Web" page -- not the "Consoles" page
  • Click on the "Start a bash console in this virtualenv" link, which you will see in the "Virtualenv:" section.
  • In the bash console that appears after that, use pip install without the "--user" flag to install the packages you need.

Perfect! It worked now! Thanks, Giles.

Alexander Tanck alexander.tanck@gmail.com

18:32 (vor 1 Minute)

an Giles i have an importerror that flask_wtf isnt found.

i followed the instructions here: https://www.pythonanywhere.com/forums/topic/13744/ but i still get the same error.

could you help me out with that?

Error running WSGI application 2021-07-21 14:02:35,535: ModuleNotFoundError: No module named 'flask_wtf' 2021-07-21 14:02:35,535: File "/var/www/0lix_pythonanywhere_com_wsgi.py", line 16, in <module> 2021-07-21 14:02:35,535: from main import app as application # noqa 2021-07-21 14:02:35,535: 2021-07-21 14:02:35,535: File "/home/0lix/LearnyWeb/main.py", line 1, in <module> 2021-07-21 14:02:35,535: from app import app 2021-07-21 14:02:35,535: 2021-07-21 14:02:35,535: File "/home/0lix/LearnyWeb/app/init.py", line 12, in <module> 2021-07-21 14:02:35,536: from app import routes 2021-07-21 14:02:35,536: 2021-07-21 14:02:35,536: File "/home/0lix/LearnyWeb/app/routes.py", line 8, in <module> 2021-07-21 14:02:35,536: from app.forms import LearnyWebForm 2021-07-21 14:02:35,536: 2021-07-21 14:02:35,536: File "/home/0lix/LearnyWeb/app/forms.py", line 1, in <module> 2021-07-21 14:02:35,536: from flask_wtf import FlaskForm

What was the exact command that you ran to install the package? And what did it print out?

thank you for your answer

i ran pip3 stall FLASK-WTF in the virtual envirnoment now it sais that requirement is already satisfied.

i dont remember that well what it printed out the first time but it looked normal

pip3 uninstall FLASK-WTF doesnt seem to work. when i try to reinstall it, it still sais that the requirement is already satisfied

Are you sure you were in the virtual environment when you ran that command? What did you do to activate it?

i clicked:

Start a console in this virtualenv in the web tab

it was already activated when it opend

Have you reloaded the website using the button on the "Web" page since you installed the package?

yes i did that several times. i also deleted the web app and reconnected it the virtual environment included

Could we look into your files? We can but we ask first.

Es you can look into my files. Thank you!

It looks like your web app works and the last error is from 2021-07-21 14:02:35,536

When I want to execute it I always get an error From flask

"Bad Request The browser (or proxy) sent a request that this server could not understand."

So maybe there is another error but it is not shown in the error log?

Is it possible to run flask with debug mode on?

i could now reproduce the error on my local device and run flask on debug mode. i could fix the error in the script now it's working.

but thank you for your help :-) sorry that i took so much time

Glad to hear that you made it work!