This is a common frustration for Python developers using Visual Studio Code. The issue usually stems from Pylance (VS Code's language server) not knowing where Poetry has installed your virtual environment, or not selecting the correct interpreter.
Here is a solid, actionable guide to fixing missing imports when using Poetry in VS Code.
poetry env info --path
Ctrl+Shift+P → Python: Select Interpreter → Enter interpreter path → paste the path above, then append /bin/python (Linux/macOS) or \Scripts\python.exe (Windows).poetry show --tree
Now, open VS Code. Look at the bottom-left corner of the window. You’ll see the Python interpreter indicator. If it says something like Python 3.9.6 ('base') or Python 3.10 ('global'), that confirms Pylance is using the wrong environment. The fix is to point it to the Poetry environment.
In your terminal (inside the project directory), run: pylance missing imports poetry link
poetry env info --path
This outputs the absolute path to Poetry’s virtual environment (e.g., /Users/me/Library/Caches/pypoetry/virtualenvs/my-project-abc123-py3.11).
In VS Code, open the Command Palette (Cmd+Shift+P or Ctrl+Shift+P). This is a common frustration for Python developers
Type Python: Select Interpreter.
Click Enter interpreter path... and paste the path you copied, appending the appropriate Python binary: Find your Poetry venv path:
poetry env info --path
bin/pythonScripts\python.exeExample full path: /Users/me/Library/Caches/pypoetry/virtualenvs/my-project-abc123-py3.11/bin/python
Reload the VS Code window (Developer: Reload Window). Pylance will now index the correct environment.