Visual Studio Code Import “flask“ could not be resolvedPylance

First of all, I use Visual Studio Code to edit the python code.
1. Check whether the phenomenon is the same as what I encountered. There are wavy lines under the flask
insert image description here

Run in the TERMINAL window of Visual Studio Code: pip --version
View the package installed by pip is placed in python 3.10, as shown in the figure below

insert image description here

  1. And the python version used by my Visual Studio Code is: 3.11.1
    insert image description here
    So, need to change from 3.11.1 to 3.10

Click on 3.11.1 64-bit in the lower right corner of step 3

insert image description here
A window will appear on the upper part of the window,
click on the blue part, my blue part is Practices ~\Desktop
5. Click on the entry with the words "Recommended" with a five-pointed star, and change from 3.11.1 to 3.10.9
insert image description here
6.
After clicking to 3.10.9,
the lower right corner changes from the original 3.11.1 to the current 3.10.9
and then look at the above code flask, there is no longer a yellow wavy line and an error.
insert image description here

Summary: The error of Import “flask” could not be resolvedPylance
appeared , which was caused by the inconsistency between the version of python used by Visual Studio Code and the version used by the pip installation package. It can be changed to the same version as the version used by pip through the above method Encoded normally.


Guess you like

Origin blog.csdn.net/m0_47505062/article/details/128900267