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

Python extension environment not working on Windows with VSCode telemetry disabled #24459

Closed
schwaerz opened this issue Nov 18, 2024 · 3 comments
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@schwaerz
Copy link

Type: Bug

Behaviour

I tried to get the python environment running in some workspace. When hovering on any shell (powershell, git bash...) I saw that there was no contribution to the python environment mentioned.

It worked when using a fresh data dir. So I looked for the settings causing this.

When I disabled the following two settings, it started working:

    // "telemetry.enableTelemetry": false,
    // "telemetry.enableCrashReporter": false,

Then I tried the new telemetry setting - same issue. As soon as I put the following line in my settings.json, the environment will no longer be activated:

    "telemetry.telemetryLevel": "off"

Expected:

Image

Got:

Image

(just openend the same workspace with telemetry disabled)

To me it looks like disabling telemetry will disable some 'experiments' which are required for enabling the python environment integration? At least I can see that there are no experiments enabled when telemetry is disabled, but following experiments are enabled if telemetry is enabled:

vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
724cj586:31013169
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
impr_priority:31102340
nativerepl1:31139838
pythonrstrctxt:31112756
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31181875

Steps to reproduce:

  1. Open some python project in VSCode. I created an empty project using pdm init. That will do.
  2. Make that telemetry is disabled as described above.
  3. If telemetry was enabled, restart VSCode.
  4. However over your default terminal (powershell, git bash, ...) to check whether the python extensions contributed anything to the environment.

For me, it doesn't as soon as I disable the VSCode telemetry.
This seems to work fine when running in WSL - but not in native Windows.

Diagnostic data

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

2024-11-18 17:26:59.445 [info] Telemetry level is off
2024-11-18 17:26:59.445 [info] Experiments are disabled, only manually opted experiments are active.
2024-11-18 17:26:59.445 [warning] Dir "c:\repositories\vsconan-test\.pixi\envs" is not watchable (directory does not exist)
2024-11-18 17:26:59.445 [info] Python interpreter path: .\.venv\Scripts\python.exe
2024-11-18 17:26:59.592 [info] > pyenv which python
2024-11-18 17:26:59.592 [info] cwd: .
2024-11-18 17:27:04.944 [info] Starting Pylance language server.

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

2024-11-18 17:28:56.587 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-11-18 17:28:56.587 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-11-18 17:28:56.587 [info] Experiment 'pythonTestAdapter' is active
2024-11-18 17:28:56.587 [warning] Dir "c:\repositories\vsconan-test\.pixi\envs" is not watchable (directory does not exist)
2024-11-18 17:28:56.587 [info] Python interpreter path: .\.venv\Scripts\python.exe
2024-11-18 17:28:56.616 [info] > pyenv which python
2024-11-18 17:28:56.616 [info] cwd: .
2024-11-18 17:29:00.839 [info] > & ./.venv/Scripts/Activate.ps1 ; echo 'e8b39361-0157-4923-80e1-22d70d46dee6' ; python ~/.vscode/extensions/ms-python.python-2024.20.0-win32-x64/python_files/printEnvVariables.py
2024-11-18 17:29:00.839 [info] shell: powershellCore
2024-11-18 17:29:01.484 [info] > ~\AppData\Local\Programs\Python\Python311\python.exe ~/.vscode/extensions/ms-python.python-2024.20.0-win32-x64/python_files/printEnvVariables.py
2024-11-18 17:29:01.484 [info] shell: powershellCore
2024-11-18 17:29:01.917 [info] Prepending environment variable PATH in collection with c:\Users\myUserName\.vscode\extensions\ms-python.python-2024.20.0-win32-x64\python_files\deactivate\powershell;C:\repositories\vsconan-test\.venv/Scripts; {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-11-18 17:29:01.917 [info] Setting environment variable VIRTUAL_ENV in collection to C:\repositories\vsconan-test\.venv {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-11-18 17:29:01.917 [info] Setting environment variable VIRTUAL_ENV_PROMPT in collection to vsconan-test-3.11 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-11-18 17:29:01.918 [info] Send text to terminal: & C:/Users/myUserName/AppData/Local/Programs/Python/Python311/python.exe c:\Users\myUserName\.vscode\extensions\ms-python.python-2024.20.0-win32-x64\python_files\printEnvVariablesToFile.py c:\Users\myUserName\.vscode\extensions\ms-python.python-2024.20.0-win32-x64\python_files\deactivate\powershell\envVars.txt
2024-11-18 17:29:02.215 [info] Starting Pylance language server.

Extension version: 2024.12.0
VS Code version: Code 1.95.3 (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Windows_NT x64 10.0.22631
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.1
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): VirtualEnvironment
System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i7-12800H (20 x 2803)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.58GB (9.10GB free)
Process Argv --user-data-dir ../test ../vsconan-test/ --crash-reporter-id daecb4ec-d188-4b9e-bd89-eabda3004a8a
Screen Reader no
VM 0%
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 18, 2024
@schwaerz
Copy link
Author

Just found a workaround. The required experiment can be enabled manually when telemetry is disabled:

    "python.experiments.optInto": [
        "pythonTerminalEnvVarActivation"
    ]

@karthiknadig
Copy link
Member

@schwaerz The workaround you have for disabling telemetry is the right one.

The activations should use the command method where it sends the command when experiments are disabled. Did that not work for you? Or were you specifically locking for python environment feature that the experiment enables.

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 18, 2024
@schwaerz
Copy link
Author

@karthiknadig actively enabling the experiment works for me.

However it took me quite some time to figure that out. Especially since this seems to work fine when running in WSL. Is this as it should be? Is there any documentation available about this somewhere?

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants