Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Error: 'No module named flask' in VSCode even when I have installed flask

I want to debug an application using Python and Flask in VSCode. I have installed Flask and the app runs perfectly fine through cmd. But, when I try to debug it through VSCode, it gives the following error:

cd 'c:\Users\Aditi\CleanHandymanApp'; 
${env:FLASK_APP}='NewApp'; ${env:PYTHONIOENCODING}='UTF-8'; 
${env:PYTHONUNBUFFERED}='1'; & 'C:\Users\Aditi\envs\CleanHandymanApp\Scripts\python.exe' 
'c:\Users\Aditi\.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py' '--client' '--host' 
'localhost' '--port' '63143' '-m' 'flask' 'run' '--no-debugger' '--no-reload'
No module named flask

Can you please help me.

like image 256
Lily Avatar asked Dec 17 '22 20:12

Lily


1 Answers

This error message can occur if you installed the python3 version of flask but Visual Studio Code tries to run your project with python2.

Make sure to select the correct version of python in the editor. This can be done by running the command Python: Select Interpreter from the Command Palette (Ctrl+Shift+P).

like image 159
confusius Avatar answered Jun 17 '23 16:06

confusius