Answer a question

I'm learning Python and part of the course setting up a webserver using Flask. I followed the steps as per the Flask installation documentation and for some reason the flask module is underlined as shown below. When I hover my mouse, I get additional information as below.

import flask could not be resolved from source pylance

The server is running fine though. Should i be ignoring the notification? If not what dependency have i missed?

Below is the code to setup the server

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello, World!'

enter image description here

enter image description here

Answers

When I did not install the module "flask", I ran into the problem you described:

enter image description here

The reason is that the module "flask" is not installed in the Python environment we currently use in VSCode.

Please use the shortcut key Ctrl+Shift+` to open a new VSCode terminal, it will automatically enter the currently selected environment, and then use the command "pip show flask" to check the installation location of the module "flask":

enter image description here

If it still shows that the module could not be resolved, it is recommended that you reinstall the module "flask".

Logo

学AI,认准AI Studio!GPU算力,限时免费领,邀请好友解锁更多惊喜福利 >>>

更多推荐