VSCode
Poetry
Python
Virtual Environments
Debugging

VSCode doesn't show poetry virtualenvs in select interpreter option

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

When a Poetry environment does not appear in VS Code's interpreter picker, the problem is usually discovery rather than creation. Either the environment does not exist yet, it lives outside the workspace patterns VS Code is checking, or the Python tooling is looking at a different machine or workspace root than Poetry is.

Confirm That Poetry Really Created an Environment

Start outside VS Code and verify that Poetry has an environment for the current project.

bash
poetry env info --path
poetry run python -V

If poetry env info --path returns nothing useful, VS Code has nothing to discover. Create the environment first:

bash
poetry install

Then reopen the interpreter picker. Many debugging sessions start with VS Code, but the most important first check is whether Poetry has actually created a virtualenv at all.

Make the Environment Easier for VS Code to Discover

Poetry often stores environments in a central cache directory rather than inside the project. VS Code can discover Poetry environments, but the most reliable layout is still an in-project .venv.

You can tell Poetry to create the environment inside the workspace:

bash
poetry config virtualenvs.in-project true
poetry install

Now the interpreter usually lives under .venv, which VS Code detects very reliably because it is part of the workspace itself.

If you prefer not to change the global Poetry setting, you can still point VS Code directly at the interpreter path. A workspace setting is the modern place to do that:

json
{
  "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
}

On Windows, the path would typically end with Scripts\\python.exe instead.

Use the Right VS Code Context

Interpreter discovery is workspace-specific. If you open the parent folder of the real Poetry project, VS Code may not connect the environment to the correct workspace.

Check these questions:

  • did you open the actual project root, the one containing pyproject.toml
  • are you working in WSL, SSH, or a container while Poetry created the env on the host machine
  • is the Python extension installed and active in the same context where the files are open

This matters a lot in remote development. A Poetry environment created on macOS will not appear inside a WSL or dev-container session, because from VS Code's point of view that is a different machine.

Refresh Discovery and Select Manually When Needed

If the environment exists but still is not listed, use Python: Select Interpreter and then choose the manual path option. Feed it the value from poetry env info --path.

For example:

bash
poetry env info --path

If the result is /Users/me/Library/Caches/pypoetry/virtualenvs/demo-py3.12, the interpreter path is usually:

text
/Users/me/Library/Caches/pypoetry/virtualenvs/demo-py3.12/bin/python

Once selected, VS Code stores that choice for the workspace. This is often faster than waiting for auto-discovery when the environment lives in Poetry's shared cache.

Also note that older guidance on python.pythonPath is outdated. Current VS Code Python tooling uses interpreter selection and modern settings such as python.defaultInterpreterPath rather than the deprecated python.pythonPath workflow.

Recent VS Code Behavior

Recent VS Code Python releases have improved Poetry discovery and even automatic environment selection in many workspaces. That is useful, but it does not remove the basic constraints:

  • the environment must exist
  • VS Code must be pointed at the correct workspace
  • the Python tooling must be running in the same local or remote context

If any of those are wrong, improved discovery features still will not show the interpreter you expect.

Common Pitfalls

The most common mistake is assuming Poetry created an environment just because pyproject.toml exists. It has to be installed first.

Another frequent problem is opening the wrong folder in VS Code, especially in monorepos. Developers also copy old advice that sets python.pythonPath, which is no longer the preferred configuration path. In remote sessions, the biggest pitfall is forgetting that host and remote environments are separate. A locally created Poetry env will not appear inside a container or SSH workspace.

Summary

  • Verify the Poetry environment exists with poetry env info --path.
  • The most reliable setup is an in-project .venv, created with poetry config virtualenvs.in-project true.
  • Open the actual project root that contains pyproject.toml.
  • In remote VS Code sessions, make sure the environment exists in the same remote context.
  • If discovery still fails, manually select the interpreter path or set python.defaultInterpreterPath for the workspace.

Course illustration
Course illustration

All Rights Reserved.