First, open a terminal in your project's root directory and locate the virtual environment path:
Open the Command Palette ( Ctrl/Cmd + Shift + P ) and run Python: Restart Language Server . This forces Pylance to clear its cache and scan your directory paths fresh.
Configure the base path using python.venvPath and point python.venvFolders to match your specific environment name: pylance missing imports poetry link
After applying a solution, verify success:
If you want a quick fix without altering how Poetry works or switching your active interpreter, you can explicitly give Pylance the exact path to your virtual environment's site-packages directory. Get the precise path of your active Poetry environment: poetry env info --path Use code with caution. Open your .vscode/settings.json file. First, open a terminal in your project's root
Open the VS Code Command Palette ( Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on Mac). Type and select .
"python.defaultInterpreterPath": "/path/to/your/poetry/venv/bin/python", "python.analysis.extraPaths": [ "$workspaceFolder/src", "$workspaceFolder" ] Get the precise path of your active Poetry
Look for an interpreter that matches your project name and contains poetry in the path.
The most common cause is that VS Code is not pointing to the Poetry virtual environment. Open your project in VS Code.