Skip to content

Venv is not being remembered #25867

Closed
microsoft/vscode-python-environments
#1397

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):
    pass

In 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

  1. github-actions commented on Mar 17, 2026

    @github-actions

    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.


    Similar 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!

  2. WellingtonNico commented on Mar 17, 2026

    @WellingtonNico
    Author

    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)

  3. WellingtonNico commented on Mar 17, 2026

    @WellingtonNico
    Author

    Update, I was able to solve the issue about wrong environment, and even with this solved the import suggestions are not working yet.

  4. WellingtonNico commented on Mar 17, 2026

    @WellingtonNico
    Author

    Just for better explaining,,

    again, it was working totally fine a few days ago, it just stopped working:

    Image

    although if I toggle more options it even show option to import from correct place:

    Image
  5. WellingtonNico commented on Mar 17, 2026

    @WellingtonNico
    Author

    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?

  6. rchiodo commented on Mar 17, 2026

    @rchiodo

    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 Interpreter to pick the correct one.

    If on reopen it's not the same one, that would be a bug on the Python extension.

  7. WellingtonNico commented on Mar 17, 2026

    @WellingtonNico
    Author

    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 Interpreter to pick the correct one.

    If on reopen it's not the same one, that would be a bug on the Python extension.

    that's what I'm telling you, I restarted it and the wrong env was there again somehow.

  8. rchiodo commented on Mar 17, 2026

    @rchiodo

    that's what I'm telling you, I restarted it and the wrong env was there again somehow.

    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.

  9. changed the title [-]Import suggestions from .venv not working[/-] [+]Venv is not being remembered[/+] on Mar 17, 2026
  10. WellingtonNico commented on Mar 17, 2026

    @WellingtonNico
    Author

    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.

  11. 8 remaining items

  12. modified the milestones: , 1.114.0 on Mar 25, 2026
  13. aiday-mar commented on Mar 30, 2026

    @aiday-mar

    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
  14. eleanorjboyd commented on Mar 30, 2026

    @eleanorjboyd
    Member

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugtriage-neededNeeds assignment to the proper sub-teamverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions