For example, you enter in the python file:
import numpy
After that, the system reports an error "Import numpy could not be resolved", there may be two reasons
Cause one
This package is not downloaded, open the command line, enter pip list
, you can see all the packages you have downloaded, if not, just restart vscode after downloading.
Reason Two
You have multiple python compilation environments, but the package is not downloaded in the compilation environment you use in vscode.
Solution:
- Press the shortcut key on the keyboard: Ctrl + shift + P
- Input: Python: Select Interpreter
3. Select the appropriate Python interpreter
As you can see, I have two python compilation environments, just choose the environment where you have downloaded various packages.