Skip to content

Selecting .venv/bin/python as an active interpreter in VSCode doesn't enable IDE features #9637

Description

@oulianov

Maintainer edit: Please set python.usePythonEnvironmentsExtension: true and check if the problem persists. See #9637 (comment) for more detail.


Hello,

I develop my Python app with uv to handle dependencies. I want to benefit from intellisense, type hints, mypy and ruff in VSCode while I develop my app. VSCode is the most popular IDE for Python developers.

Usually, I create the a virtual env with python -m venv. I then select the virtual env in VSCode as an "Active Interpreter". This adds support from all the VSCode features mentioned.

With uv, a folder .venv is created. However, when I select this .venv as an active interpreter in VSCode, nothing changes in my editor. Intellisense, type hints, and mypy don't work. Installed modules are not found. Custom modules are not found either.

When I run "Reload Window", this results in a toast on the bottom right "Reactivating terminals" that never completes.

Restarting VSCode with the config doesn't make it work.

This means for now I need to have multiple virtual environment running. One for uv, another for development. This voids the usefulness of uv for package management.

How to make uv virtual environments work with VSCode?


[EDIT] HERE IS A WORKAROUND! Here's a foolproof technique my buddy @Jeerhz showed me to select a uv .venv as an active interpreter in vscode.

  1. First, copy the absolute path to the .venv. Not to the /bin/python, only the .venv folder.
Image
  1. Do Cmd+Shift+P, then look for "Python: Select interpreter". Press Enter. Select the option: "Enter interpreter path".
Image
  1. Now in this field you copy paste the absolute path to the .venv folder.
Image Image

Press enter and now you have the right Python environment with all the dependencies.

Selecting .venv as an active interpreter in VSCode works. But selecting .venv/bin/python doesn't.


Recommendation: use an extension like teticio.python-envy to automatically set the interpreter path based on the file you're currently looking at, compare #9637 (comment) . This is what I currently use and it has been working quite well in my monorepo setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalThe problem is with another package or dependency (not uv)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions