When I start the debugger in VSCode, the conda environment only gets activated after the debugging process has stopped with a "Missing required dependencies" import error. Immediately restarting the debugger works fine then.
This problem occurs with the Anaconda "base" and other environments.
Test code: import_pandas.py
import pandas
print("Pandas import succeeded!")
VSCode Python Debug Console:
Microsoft Windows [Version 10.0.16299.1146]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\peter\demo>cd c:\Users\peter\demo &&
cmd /C "set "PYTHONIOENCODING=UTF-8" &&
set "PYTHONUNBUFFERED=1" &&
C:\Users\peter\AppData\Local\Anaconda3\python.exe
c:/Users/peter/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/ptvsd_launcher.py
--default --client --host localhost --port 49530
c:\Users\peter\demo\import_pandas.py "
...
ImportError: Missing required dependencies ['numpy']
C:\Users\peter\demo>C:/Users/peter/AppData/Local/Anaconda3/Scripts/activate
(base) C:\Users\peter\demo>conda activate base
(base) C:\Users\peter\demo>
Note that conda gets automatically activated after the debugger stopped.
Once after the environment got activated, the debug process doesn't fail anymore:
(base) C:\Users\peter\demo>cd c:\Users\peter\demo &&
cmd /C "set "PYTHONIOENCODING=UTF-8" &&
set "PYTHONUNBUFFERED=1" &&
C:\Users\peter\AppData\Local\Anaconda3\python.exe
c:/Users/peter/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/ptvsd_launcher.py
--default --client --host localhost --port 49544
c:\Users\peter\demo\import_pandas.py "
Pandas import succeeded!
Is there any way to have conda activated prior to calling the debugger for the first time?