Add the path to your site-packages (found via pip show ):
You’ve just scaffolded a pristine new project. You ran poetry add fastapi (or pandas, or numpy), the install finished without a hitch, and your pyproject.toml looks beautiful. You open VS Code, type import fastapi , and then you see it. pylance missing imports poetry hot
– Pylance.
Pylance restarts. The import errors vanish. Autocomplete works. This is the "hot" fix that solves 90% of cases. Add the path to your site-packages (found via
If your Poetry environment requires environment variables for Pylance to resolve imports (e.g., PYTHONPATH modifications), create a .env file in your project root: the install finished without a hitch