marsacom
marsacom

Reputation: 41

VS-Code python module imports yellow even though theyre installed

enter image description hereAll of the modules are imported and have been but now out of nowhere these 3 are showing up yellow and have an error message along the lines of this... Import "numpy" could not be resolved Pylance(reportMissingImports)

Upvotes: 4

Views: 4996

Answers (1)

JialeDu
JialeDu

Reputation: 9883

If you have multiple python environments on your machine, please choose the correct interpreter for vscode.

Choose an interpreter:

  1. Use Ctrl+Shift+P to open the command palette

  2. search and select Python:Select Interpreter

  3. Choose the right interpreter

There are two ways to solve the problem here:

    1. Confirm what environment your package is installed in (for example using pip show ... command)

      enter image description here

    2. choose the interpreter for that environment for vscode

      enter image description here

    1. Choose an interpreter you want to use for vscode

      enter image description here

    2. Create a new terminal to activate the selected environment

      enter image description here

    3. Install the packages you need for this environment in the new terminal

      enter image description here

Upvotes: 6

Related Questions