New "conda run" method of running python file results in errors · Issue #18634 · microsoft/vscode-python (original) (raw)

Issue Type: Bug

Prior to update February 2022 1.65 you had to set: "python.terminal.activateEnvironment": true to make VSCode activate the selected environment with Conda and not to use the base one, now you need to set this option to false to be able to run the environment.

Step to Reproduce:
1- Use Conda as Python interpreter in VSCode
2- Set in VSCode a Python environment different from "base"
3- Set "python.terminal.activateEnvironment": true
4- If you have an open terminal, kill it
5- Run your code.
At this step you will note that the terminal run conda activate <env_name> and then & conda run -n <env_name> --no-capture-output --live-stream python <full_filePath> and if the library you are importing is not in the "base" environment, you will get the error of missing module.

Error examples:

Fix:
set "python.terminal.activateEnvironment": false in your VSCode settings, reset terminal and it will run only & conda run -n <env_name> --no-capture-output --live-stream python <full_filePath>

Expected Results:
Not sure if the expected behaviour is to set "python.terminal.activateEnvironment" to True or to False, at previous issues like #9507, to set it False was a quick fix until an update was pushed.
As a Conda user, this new behaviour would have saved me the trouble of setting "python.terminal.activateEnvironment" to True to use my environments (There is no warning about this so you require a bit of research to work with conda environments for the first time)

VS Code version: Code 1.65.0 (b5205cc8eb4fbaa726835538cd82372cc0222d43, 2022-03-02T11:12:08.962Z)
OS version: Windows_NT x64 10.0.19043
Restricted Mode: No

System Info

Item Value
CPUs Intel(R) Core(TM) i5-4430 CPU @ 3.00GHz (4 x 3000)
GPU Status 2d_canvas: enabledgpu_compositing: enabledmultiple_raster_threads: enabled_onoop_rasterization: enabledopengl: enabled_onrasterization: enabledskia_renderer: enabled_onvideo_decode: enabledvulkan: disabled_offwebgl: enabledwebgl2: enabled
Load (avg) undefined
Memory (System) 15.68GB (8.00GB free)
Process Argv --crash-reporter-id 352ea43a-dc87-43d8-b0c8-257406ae7a14
Screen Reader no
VM 0%

Extensions (7)

Extension Author (truncated) Version
gitlens eam 12.0.1
gitkraken-authentication git 1.0.3
python ms- 2022.2.1924087327
vscode-pylance ms- 2022.3.0
jupyter ms- 2022.2.1020642448
jupyter-keymap ms- 1.0.0
jupyter-renderers ms- 1.0.6

A/B Experiments

vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30433507
vsclayoutctrc:30437038
vsrem710cf:30416617
vscop841cf:30447410
dsvsc008:30440022
pythonvsnew555:30442236
vsbas813:30436447
vscscmwlcmt:30438805
vscgsvid2:30447481
helix:30440343
vsnot107cf:30443615