Skip to content

Pylance stopped using the workspace .venv as defined in user settings.json and use some random other folder .venv #25571

@vemonet

Description

@vemonet

Environment data

  • Pylance version: 2025.9.1
  • OS and version: macOS tahoe 16.0.1
  • Python version (& distribution if applicable, e.g. Anaconda): uv installed python .venv in this case 3.13 uv 0.8.23 (00d3aa378 2025-10-04)

Code Snippet

Set this in the settings.json

{
  "python.venvPath": "${workspaceFolder}/.venv"
}

I am not even sure this is really useful, but I have already had this from the past and it always worked this way

Then try to import a dependency in your project

import pydantic

And pydantic is flagged as not installed because

Repro Steps

Not sure how to actively reproduce this... If I knew it would probably already be solved

  1. use uv to work with multiple python project with each project dependencies installed in .venv
  2. at some point pylance might break and start using a random folder instead of the workspace folder

Expected behavior

Pylance should use the currently opened workspace folder base .venv, and not any random folder in my laptop

I have set this in my use settings.json to explicitly make sure python LSPs knows that I just want to use local .venv in the workspace folder (quite basic)

{
  "python.venvPath": "${workspaceFolder}/.venv"
}

It has been working for years

Actual behavior

I have asked to github copilot why pylance was not properly resolving dependencies, and it used the pylancePythonEnvironments MCP tool to find that pylance was just casually using the .venv of a completely different folder. Which I never set anywhere (I have been using this other project recently but that's all, like I usually do since I work on multiple projects)

Python environments for 'file:///Users/vemonet/dev/eosc/data-commons-mcp'

### Current python environment ###
'/Users/vemonet/dev/sib/ELIXIR-TrP-KG-training-metadata/.venv/bin/python'

### Python environments available ###
/usr/bin/python3
/opt/homebrew/bin/python3
/opt/homebrew/anaconda3/bin/python
/Users/vemonet/dev/eosc/data-commons-mcp/.venv/bin/python

Logs

Any idea why pylance all of a sudden behaves like this? It happened in the past that pylance struggles to find locally installed dependencies, but usually this is fixed by restarting VSCode or reinstalling the dependencies. In this case doing the 2 many times have not yet solved the problem.

Resolving dependencies using the workspace project .venv seems like the basic default behavior, it's hard to understand how all of sudden pylance decides to use random folders that are not even opened in the current workspace

Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions