vscode-python: Correct Python environment in terminal no longer loads

Type: Bug

Behaviour

Expected vs. Actual

Broke a couple days ago (around 9/5/23?). Previously, when a Python environment was selected in the bottom right (I’m using WSL2), when I opened a terminal, the corresponding venv Python environment would automatically load.

Now, I have to manually source the venv activate script.

I have tried putting "python.experiments.optInto": "pythonTerminalEnvVarActivation" into my remote WSL settings.json, but this does not help. Even upon restarting VS Code.

I have looked through both here and here but I have not found anything helpful. Perhaps I missed something.

Thanks in advance.

Steps to reproduce:

  1. Set my Python environment in the bottom right corner.
  2. Hit Ctrl-` to open a terminal.
  3. Typing python in the terminal and importing a library I know exists (using e.g. import streamlit) throws an importerror.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.8
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): PipEnv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2023-09-07 12:13:14.851 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2023-09-07 12:13:14.851 [info] Experiment 'pythonaa' is active
2023-09-07 12:13:14.851 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-09-07 12:13:14.851 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-09-07 12:13:14.851 [info] Experiment 'pythonSurveyNotification' is active
2023-09-07 12:13:14.851 [info] Experiment 'pythonTestAdapter' is active
2023-09-07 12:13:14.851 [info] Test server listening.
2023-09-07 12:13:14.851 [info] Python interpreter path: ~/.local/share/virtualenvs/testing_streamlit-BSTEB2XH/bin/python
2023-09-07 12:13:15.546 [info] > conda info --json
2023-09-07 12:13:15.622 [info] > . ~/.local/share/virtualenvs/testing_streamlit-BSTEB2XH/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-server/extensions/ms-python.python-2023.15.12301911/pythonFiles/printEnvVariables.py
2023-09-07 12:13:15.622 [info] shell: bash
2023-09-07 12:13:16.390 [info] Starting Pylance language server.

User Settings


languageServer: "Pylance"

experiments
• optInto: ["pythonTerminalEnvVarActivation"]

Extension version: 2023.15.12301911 VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:22:42.175Z) OS version: Windows_NT x64 10.0.22621 Modes: Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2

System Info
Item Value
CPUs 12th Gen Intel® Core™ i7-1265U (12 x 2688)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.44GB (10.67GB free)
Process Argv –crash-reporter-id a11beee0-9324-4740-85d9-6f0e82af3399
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.10.16.3-microsoft-standard-WSL2
CPUs 12th Gen Intel® Core™ i7-1265U (12 x 2688)
Memory (System) 15.36GB (14.15GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30792226
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vsccc:30803844
2e4cg342:30602488
89544117:30613380
2i9eh265:30646982
showlangstatbar:30737416
962ge761:30823813
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
asynctok:30821568
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015:30829745

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 1
  • Comments: 31 (1 by maintainers)

Most upvoted comments

Thanks @karrtikr. Looks like this was fixed with an update to Pylance pre-release just now, v2023.9.12. E.g., no longer complaining that it can’t find the streamlit library. The (base) conda environment still no longer gets deactivated but I’m fine with that. Thanks for your help!