'Flask runs out of virtual environment

I was working in virtual environment but I removed the virtual environment folder in purpose. But I still can run flask restful application as below, while new empty virtual environment(there are no libraries in site packages but even application works like old virtual environment) is active.

flask run 

I thought it should have been failed and complaining like:

no module named flask

, because I removed the old proper virtual environment and installed new one then activated it.

And here is the point, when I try the run the main script as below

python3 app.py

It complains as expected:

no module named flask

It seems that when I run with flask run it is not using virtual environment even virtual environment is active. Because of this reason I can't test my application with other python versions and can't test if requirements are installed and run in new other virtual environments. I couldn't understand this behavior of the flask for any help I appreciate.

Thanks in advance.



Solution 1:[1]

You may have Flask globally installed.

pip list | grep flask

You can remove that:

pip uninstall flask

or

Create virtualenv with --no-site-packages option:

virtualenv --no-site-packages venv
source venv/bin/activate

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ghilas BELHADJ