If you are a Python developer using Visual Studio Code, you have likely experienced a unique flavor of frustration: your terminal runs the code perfectly, poetry show --tree lists all your dependencies, yet your editor is littered with angry yellow squiggles. Hovering over the import reveals the dreaded message: "Import 'xyz' could not be resolved" (Pylance).
This issue occurs most frequently when using Poetry for dependency management. Poetry’s unique approach to virtual environment management and project isolation often confuses Pylance, Microsoft’s default, powerful language server.
In this article, we will dissect why this happens, provide step-by-step solutions, and show you how to permanently link Poetry environments to Pylance. pylance missing imports poetry link
The simplest method requires no configuration files—just a few clicks. However, you must repeat this every time you create a new Poetry project.
Step-by-Step:
After selection, wait a few seconds for Pylance to restart. The yellow squiggles should disappear.
Pros: Instant, no config files.
Cons: Manual, error-prone, not repeatable across team members. If you are a Python developer using Visual
You have a Poetry-managed project. Your code runs perfectly with poetry run python script.py, but Pylance (VS Code’s Python language server) underlines imports in red, saying “import could not be resolved”.