You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pylance stopped using the workspace .venv as defined in user settings.json and use some random other folder .venv #25571
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
importpydantic
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
use uv to work with multiple python project with each project dependencies installed in .venv
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
Hi Vincent Emonet (@vemonet), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Explanation:
Pylance resolves imports based on the selected Python interpreter, not just the python.venvPath discovery setting.
Setting "python.venvPath" only tells Pylance where to look for environments; it does not automatically pick that venv for analysis if another interpreter was previously selected.
Potential Duplicate Issues – These issues may be duplicates of your report, but may differ in some of the details.
The team will respond to your issue shortly. Please note this is a trial feature and may not be fully accurate. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or was incorrect, please give it a 👎. Your feedback helps us improve!
I have added "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", to the user settings.json but still exact same issue
That is really problematic, because it completely prevents me to use VSCode for python projects, which is needed for my work, and I will need to cancel my github copilot subscription to move to zed if this persists
I am not going to manually change the interpreter, because I constantly switch projects and I really need my IDE to be able to pick up the current workspace without manual intervention everytime
Activity
github-actions commentedon Nov 10, 2025
Hi Vincent Emonet (@vemonet), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Explanation:
python.venvPathdiscovery setting."python.venvPath"only tells Pylance where to look for environments; it does not automatically pick that venv for analysis if another interpreter was previously selected.Potential Duplicate Issues – These issues may be duplicates of your report, but may differ in some of the details.
Potential Workarounds:
⌘+Shift+P), run Python: Select Interpreter, and choose${workspaceFolder}/.venv/bin/python..vscode/settings.json:{ "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" }The team will respond to your issue shortly. Please note this is a trial feature and may not be fully accurate. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or was incorrect, please give it a 👎. Your feedback helps us improve!
vemonet commentedon Nov 10, 2025
I have added
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",to the usersettings.jsonbut still exact same issueThat is really problematic, because it completely prevents me to use VSCode for python projects, which is needed for my work, and I will need to cancel my github copilot subscription to move to zed if this persists
I am not going to manually change the interpreter, because I constantly switch projects and I really need my IDE to be able to pick up the current workspace without manual intervention everytime
rchiodo commentedon Nov 10, 2025
This is not a setting that Pylance controls. It's controlled by the Python extension. It determines what interpreter is set. Transferring.
rchiodo commentedon Nov 10, 2025
I believe the Python extension defaults to using whatever venv is currently active when VS code starts up. That might be what you're seeing.
vemonet commentedon Nov 12, 2025
I have found out a command in the command palette
Python: Clear Workspace Interpreter Settingthat seems to have fixed it