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:
- Open up your command pallets and type : "python: select interpreter".
- Select your newly created python interpreter inside your venv.
- add
"python.terminal.activateEnvironment": true
to yoursetting.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.