Repository navigation
Venv is not being remembered #25867
Description
Hello guys, I have a problem here, vscode stopped suggesting imports for python, but only the ones inside .venv folder, my dependencies in this case of course. I tried many things, since resintall until creating a new user in my computer with a fresh vscode install, none worked, I didn't change any of my configs, it just stopped working.
Just to make sure you understand, I can debug my code, normally, it runs perfectly, I don't have a message saying that a module was not found, if I import them manually everything works, only the import completions are not working anymore.
Environment data
- Pylance version: 2026.1.1
- OS and version: MacOS latest
- Python version: 3.13
Code Snippet
class MyView(LoginRequiredMixin):
passIn simple situations like this, LoginRequiredMixin from django should have been suggested in the imports popup.
Repro Steps
New repo(but with old repos same problem), full vscode reinstall, including deleting all related folders and cache folders, virtual environment created, dependencies installed and python interpreter selected correctly.
My python global configs:
{
"python.analysis.importFormat": "absolute",
"python.analysis.autoImportCompletions": true,
"python.analysis.indexing": true,
"python.analysis.persistAllIndices": true,
"python.analysis.inlayHints.pytestParameters": true,
"python.analysis.typeCheckingMode": "off",
"python.analysis.cacheLSPData": true,
"python.analysis.logLevel": "Trace",
"python.analysis.enableEditableInstalls": true,
"python.analysis.userFileIndexingLimit": -1,
"python.languageServer": "Pylance",
"[env]": {
"editor.formatOnSave": false
},
"python.analysis.packageIndexDepths": [
{
"name": "",
"depth": 4,
"includeAllSymbols": false // I always used this way, but I tried with `true` and didn't work also
}
],
"python.analysis.autoIndent": true,
"python.analysis.inlayHints.callArgumentNames": "all",
"python.analysis.completeFunctionParens": false,
"python.analysis.enablePytestSupport": true,
}Expected behavior
I expect pylance to see my dependencies and suggest import automatically.
Actual behavior
I looks like pylance can only see my own code.
Logs
No error logs, the logs shows only my own code being indexed, its loo long to paste it here.
Activity
github-actions commentedon Mar 17, 2026
Hi Wellington Adriano Nicoletti de Abreu (@WellingtonNico), 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.
Potential Duplicate Issues – These issues may be duplicates of your report, but may differ in some of the details.
.venv– import detection for modules in.venvstopped working. Unable to find modules in.venv(reportMissingImports) pylance-release#1375Similar Issues (FYI only, not solutions)
The following issues may or may not be related to your report. They are provided for reference only, as they may describe similar symptoms, affect the same feature, or address related concerns, but may not be the same issue.
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!
WellingtonNico commentedon Mar 17, 2026
Update, may be I can see the problem now:
my folder structure is like this:
myuser/projects/python/
myuser/projects/csharp/
so I have many python projects in the same root folder, I'm not saying this is the cause, just explaining that could have something todo with this.
what hapened today, I was trying to solve in in another repo, it was a very simple fastapi app, then I imported BaseModel from pydantic, when I use ctrl+click to go to the BaseModel class file, the vscode took me to the environment from another repo, it is kind of lost with the environments, even if I select it correctly.
then I uninstalled python using homebrew, and tried installing it with pyenv, I just installed pyenv by the way, and the same problem happened(of course I deleted old .venv folder, created a new one and installed as deps again)
WellingtonNico commentedon Mar 17, 2026
Update, I was able to solve the issue about wrong environment, and even with this solved the import suggestions are not working yet.
WellingtonNico commentedon Mar 17, 2026
Just for better explaining,,
again, it was working totally fine a few days ago, it just stopped working:
although if I toggle more options it even show option to import from correct place:
WellingtonNico commentedon Mar 17, 2026
Update, about the case of vscode automatically choosing the .venv from other repo, it still happens, like I select the interpreter, reload the page and it's pointing to other repo again, it looks like not persisting the config and may be this is causing some indexing conflict?
rchiodo commentedon Mar 17, 2026
I believe the Python extension will attempt to pick your environment automatically when you open VS code. If there's already a venv active, it will pick that one.
It is supposed to remember the one picked if you change it after that though.
Run
Python : Select Interpreterto pick the correct one.If on reopen it's not the same one, that would be a bug on the Python extension.
WellingtonNico commentedon Mar 17, 2026
that's what I'm telling you, I restarted it and the wrong env was there again somehow.
rchiodo commentedon Mar 17, 2026
If that's the case, it's the Python extension's fault. We don't pick or interfere with the selected interpreter. We just ask what it is.
I'll transfer this issue.
[-]Import suggestions from .venv not working[/-][+]Venv is not being remembered[/+]WellingtonNico commentedon Mar 17, 2026
Update,
I notice when I enter a python project, and set interpreter to the one inside the project, and open a second window and also select its respective interpreter, then a close one windows, and then in the window that is still opened I switch to other project, the other project kind of automatically uses the last enviroment selected, in this scenario it was the enviroment of the last window closed.
very weird, it looks like loosing the reference of what python interpreter is selected.
8 remaining items
feat: enhance getVenvForWorkspace to prioritize persisted selections (m…
aiday-mar commentedon Mar 30, 2026
On up to date, VS Code, I select the interpreter to be a local venv, but I don't see it appear in the status bar. Nor do I see any indication of what the current venv is.
Screen.Recording.2026-03-30.at.12.40.31.mov
eleanorjboyd commentedon Mar 30, 2026
The status bar will only appear if you have a python file open. Then it should auto-select without the need to do the command palette command