我想在 VSCode 中使用 Python 和 Flask 调试应用程序。我已经安装了 Flask,并且该应用程序通过 cmd 运行得非常好。但是,当我尝试通过 VSCode 调试它时,它给出了以下错误:
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
你能帮我么。
最佳答案
如果您安装了 flask
的 python3 版本,则会出现此错误消息。但是 Visual Studio Code 尝试使用 python2 运行您的项目。
确保在编辑器中选择正确的 python 版本。这可以通过运行命令 Python: Select Interpreter
来完成。从命令面板 (Ctrl+Shift+P)。
关于python-3.x - 出现错误 : 'No module named flask' in VSCode even when I have installed flask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53355059/