I've found already similar questions here, but could not find specific solution. I've got virtual environment, which is activated and running, and within it I've installed flask-wtf module, as:
pip install flask-wtf
Then, there is script called "test.py", which contiains from flask_wtf import FlaskForm -> and when it is started from terminal as
python test.py
Error is raised, as
from flask_wtf import FlaskForm
ModuleNotFoundError: No module named 'flask_wtf'
Command
which flask_wtf
returns nothing. But, I could see flask_wtf folder in flaskEnv/lib/python3.6/site-packages folder (where flaskEnv - is directory for virtual environment).
Following the advise, which I've found here on website, running script as
/home/kosist/Documents/Environments/flaskEnv/bin/python test.py
works just fine - script is executed without error. But - why it happens like this? I don't want to enter all the time full path to python, and moreover, command
which python
returns the following:
/home/kosist/Documents/Environments/flaskEnv/bin/python
so calling python already refers to that path!
Also, script works, if flask-wtf module is installed globally, via
sudo pip install flask-wtf
Then I could run script as
python test.py
and everything works.
Could someone, please, help and explain, what is going on, and how to fix it? Because I'm afraid, that I'm missing some simple key point about calling modules from virtualenv, and similar situation could happen to any of the possible installed modules.