Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While creating virtual environment Python extension does not prompt with venv notification #16613

Closed
Debkmr opened this issue Nov 3, 2020 · 48 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority info-needed Issue requires more information from poster investigating We are looking into the cause of the issue

Comments

@Debkmr
Copy link

Debkmr commented Nov 3, 2020

While creating virtual environment VS Code does not prompt with venv notification
Capture

@JoshuaPartlow
Copy link

Hi @Debkmr - Just to confirm, you're not seeing a VS Code notification that a virtual environment has been created? The one that should offer to let you set it as the default for the workspace?

@Debkmr
Copy link
Author

Debkmr commented Nov 4, 2020 via email

@Aryankpoor
Copy link

I faced this issue earlier when vscode was running too many processes at the same time, so the notification comes a little late

@Debkmr
Copy link
Author

Debkmr commented Nov 4, 2020

I am not sure, I am still looking for a work around.

@Aryankpoor
Copy link

Is your vscode the latest version?

@Debkmr
Copy link
Author

Debkmr commented Nov 5, 2020 via email

@JoshuaPartlow
Copy link

One more question, are you able to activate the environment from the VS Code prompt? I notice in your image that it failed, but it also looks like the environment name wasn't right in that attempt venv vs .venv. Thanks!

@Debkmr
Copy link
Author

Debkmr commented Nov 5, 2020 via email

@JoshuaPartlow
Copy link

Small thing to check, but when you run activate, are you definitely running activate.ps1 (vs activate.bat). Can you try running with the full extension .venv\scripts\activate.ps1

@Debkmr
Copy link
Author

Debkmr commented Nov 6, 2020

Error
This is the error I am getting

@JoshuaPartlow
Copy link

Hi @Debkmr - That's an expected issue when running a PowerShell script as execution is restricted by default. You can read about the issue and some solutions here. Essentially, I believe you can either change the execution policy for the process (as discussed in the VS Code Python tutorial here) or there's also a Windows setting you can change to allow the running of local unsigned PowerShell scripts (start -> search developer settings -> PowerShell) in general. Alternatively, you could use CMD as your integrated terminal with the .bat file instead of PowerShell. Does that help?

@JoshuaPartlow
Copy link

If this is still an ongoing issue, please reopen.

@standi98
Copy link

standi98 commented Jul 5, 2021

I have this exact issue at the moment. I can activate the viritual enviroment once it is created, but in order to set it as the default one for my workpace I have to manualy add it to the "settings.json" file. It takes a cuple of minutes from the moment it is created to when it shows up in the list over interpreters, and the prompt for adding it to the workspace never shows up.

@gregvanl
Copy link

gregvanl commented Jul 5, 2021

@luabud for visibility

@luabud luabud reopened this Jul 5, 2021
@luabud luabud transferred this issue from microsoft/vscode-docs Jul 5, 2021
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jul 5, 2021
@luabud
Copy link
Member

luabud commented Jul 5, 2021

I was able to reproduce this, so I'm transferring it to the Python extension repo.

@karthiknadig karthiknadig added area-environments Features relating to handling interpreter environments triage bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Jul 6, 2021
@plto2007
Copy link

hello, any updates? I am also facing this issue

@omidshojaee
Copy link

@karthiknadig I know I can select the interpreter manually. That's what me and everyone else is doing now. I want to know why automatic detection of virtual environment was working before, and now it doesn't. Why you MS developers touch something that works perfectly?

@omidshojaee
Copy link

@karthiknadig
This is my current environment. It is not working.
Screenshot 2021-09-04 005835
Screenshot 2021-09-04 005952

@karthiknadig
Copy link
Member

@omidshojaee We had to build a new system because the old one was literally preventing users from running python extension some scenarios (especially in cases where people used shared resources). File system watching is also expensive, and can slow down processing. So the new discovery system only uses resources as needed. Our intent is to get the same experience was the old one but reduce the consumption of system resources as we do it.

@karrtikr Do we need verbose logging or just info logs to get the details on this issue?

@karrtikr
Copy link

karrtikr commented Sep 3, 2021

Verbose and info logging are the same right now.

@omidshojaee Please set the user setting python.logging.level to info, reload the window, activate the extension, create a new virtual env and provide the logs as mentioned in the issue template.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@karrtikr karrtikr added info-needed Issue requires more information from poster investigating We are looking into the cause of the issue labels Sep 3, 2021
@karrtikr karrtikr self-assigned this Sep 3, 2021
@karrtikr
Copy link

karrtikr commented Sep 3, 2021

@omidshojaee Can you try the following VSIX and see if it works: https://github.com/microsoft/vscode-python/suites/3679707781/artifacts/89611045

Use Extension: Install from VSIX command in the command palette (CTRL+SHIFT+P) to install the VSIX. If it doesn't help, please provide the logs asked earlier.

@omidshojaee
Copy link

@karrtikr
Copy link

karrtikr commented Sep 4, 2021

It seems the extension is not activated. You need to open a python file to activate the extension first and then send the content of Python output channel.

@omidshojaee

This comment has been minimized.

@karrtikr
Copy link

karrtikr commented Sep 4, 2021

It always activated only after opening a python file, or if we detect you're likely on a python project. Once you activate the extension, please try the steps I provided and leave a comment to that effect.

@omidshojaee
Copy link

@karrtikr

The extension always activated after opening a python file.

The bug reported here is not about that. It's about detecting the python interpreter after creating the virtual environment.

@karrtikr
Copy link

karrtikr commented Sep 4, 2021

We realize that. We're asking you to activate the extension by opening a python file and try creating a virtual environment. If the prompt doesn't show up, send the logs asked earlier to help diagnose the issue.

@omidshojaee

This comment has been minimized.

@karthiknadig
Copy link
Member

Python extension cannot detect any python environment if it is not activated. It never was capable of that. If extension was always activated for you then there are these possibilities:

  1. either you had another extension that depended on python extension that always activated it
  2. you had files in the folder that we register with VS Code to trigger activation on. like these files below:
       "workspaceContains:mspythonconfig.json",
        "workspaceContains:pyproject.toml",
        "workspaceContains:Pipfile",
        "workspaceContains:setup.py",
        "workspaceContains:requirements.txt",
        "workspaceContains:manage.py",
        "workspaceContains:app.py" 
  1. there was a bug in VS Code that activated the extension for you in an empty folder.

This requirement to have a python file open to activate has existed in a long time (since extension was created). So, if the extension is not activated it won't detect environments being created. If previous version of the extension was activating for you in an empty folder (not because of other extension that depend on it), then that is a bug that should be filed on VS Code.

@omidshojaee

This comment has been minimized.

@karrtikr karrtikr changed the title While creating virtual environment VS Code does not prompt with venv notification While creating virtual environment Python extension does not prompt with venv notification Sep 4, 2021
@karrtikr
Copy link

karrtikr commented Sep 4, 2021

There, fixed the title for you.

VSCode used to show a prompt right after creating the virtual environment that it is detected and offered to set it as the default for project.

VSCode was never responsible for the prompt. It's the Python extension in VSCode which showed the prompt. Your Python extension is not enabled, hence you don't see the prompt, simple.

@karthiknadig
Copy link
Member

karthiknadig commented Sep 4, 2021

That prompt comes from python extension, we show it when we detect a new environment.

const selection = await this.appShell.showInformationMessage(
Interpreters.environmentPromptMessage(),
...prompts,

Python extension detects or can detect environments only after activation. we cant detect virtual environments created when extension is not activated. You are not providing us the right information to help you here.

@omidshojaee

This comment has been minimized.

@omidshojaee

This comment has been minimized.

@omidshojaee

This comment has been minimized.

@microsoft microsoft locked as too heated and limited conversation to collaborators Sep 4, 2021
@karthiknadig
Copy link
Member

karthiknadig commented Sep 4, 2021

The extension cannot detect virtual environment (or show prompts) if it is not activated. At this point the conversation has unfortunately gone off track and this is not helping us resolve the issue (which we are actively working to resolve).

@karthiknadig karthiknadig added this to the August Recovery milestone Sep 8, 2021
@karrtikr
Copy link

Fixed in the stable release, feel free to open new issues if that isn't the case.

@karthiknadig karthiknadig removed their assignment Oct 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority info-needed Issue requires more information from poster investigating We are looking into the cause of the issue
Projects
None yet
Development

No branches or pull requests