Home > database >  how do I solve the Pylance(reportMissingImports)?
how do I solve the Pylance(reportMissingImports)?

Time:04-28

I used pip install fastapi to download it in my virtual environment, in terminal but when I try to import from it it shows up as a missing import.

CodePudding user response:

If you want to install a package into your specific virtual environment, you need to first "activate" that environment. Likewise, if you want to run your script in that environment, you need to first "activate" it. You can do this manually but preferably let VSCode handle it for you.

In order to tell VSCode(especially the language server which is pylance) to use that environment:

  1. Open up your command pallets and type : "python: select interpreter".
  2. Select your newly created python interpreter inside your venv.
  3. add "python.terminal.activateEnvironment": true to your setting.json file. This will automatically activate your venv whenever you open your integrated terminal.

CodePudding user response:

Please select the appropriate interpreter for your running environment.

ctrl shift P

and then choose the one like picture.

enter image description here

  • Related