Anup
Anup

Reputation: 107

ModuleNotFoundError: No module named 'flask_wtf' in python

I'm new to python so please be patient if i ask a silly question. I am trying to use flask wtf class as seen in a tutorial. My first line of the program is from flask_wtf import FlaskForm

It gives me the error ModuleNotFoundError: No module named 'flask_wtf' I have followed the following steps to make sure i have activated the virtual environment and flask wtf was installed in the virtual environment and not global.

Step 1: Went to the virtual environment and activated the environment C:\Users\Shraddha\PycharmProjects\FlaskProject\venv\scripts activate

Step 2: Installed flask wtf C:\Users\Shraddha\PycharmProjects\FlaskProject\venv\scripts pip install flask-wtf

I see that flask-wtf is installed correctly in the folder C:\Users\Shraddha\PycharmProjects\FlaskProject\venv\Lib\site-packages

However when i try to run it using command prompt it does not give me anything and when i try to run it using sublime text it gives me ModuleNotFoundError: No module named 'flask_wtf' error.

I know this is a flask_wtf import error because other programs are executing as expected. Any help ? enter image description here

Upvotes: 2

Views: 2072

Answers (2)

Wasimkhana
Wasimkhana

Reputation: 21

I faced same issue and tried all the approaches given on stackoverflow ImportError: No module named flask_wtf but didn't work for me. I am using ubuntu 20.04 LTS operating system.

Note: To follow the given step you must activate your virtual environment.

I used:

pip3 freeze

which listed following directories libries in my virtual environment

Then i tried the below command in the same directory

git clone git://github.com/lepture/flask-wtf.git

cd flask-wtf/

python3 setup.py install

Through the above commands i successfully installed flask_wtf as show below installed flask_wtf

but then i faced the below error as i used email_validator in my forms.py file:

Exception: Install 'email_validator' for email validation support

Then I installed email_validator using following command

pip3 install email_validator

Then i successfully run my flask application. I am sure it will work for you too.

Upvotes: 1

Robert
Robert

Reputation: 21

If you start your virtual environment in the same dir as the file you are running doesn't that give access to the libraries in the install (ie everything shown in 'pip freeze' for the env)?

Upvotes: 2

Related Questions