VsCode error: Import [module] could not be resolved solution

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:

  1. Press the shortcut key on the keyboard: Ctrl + shift + P
  2. Input: Python: Select Interpreter
    3. Select the appropriate Python interpreter insert image description here
    insert image description here
    As you can see, I have two python compilation environments, just choose the environment where you have downloaded various packages.

Guess you like

Origin blog.csdn.net/qq_52109814/article/details/123154322