I beat my head on this for far too long… launching VS Code from an Anaconda Prompt both feels clunky and didn’t really work for integrated Powershell terminals (the default VS Code integrated terminal on Windows)
I wanted to be able to launch VS Code from any prompt (and usually the Windows menu shortcut) and still interact with Conda.
These two methods both worked for Anaconda 2020.02, VS Code 1.44.0, on Windows 10.
Easy & Quick
Switch VS Code to use cmd.exe as the default integrated terminal shell by:
- opening the command palette (
Control-Shift-P) - search for
Terminal: Select Default Profile - select
Command Prompt
Harder / Powershell
- add the location of
condato your PATH (if you did not add it via the installer). For me on an “All Users” install this isC:\ProgramData\Anaconda\Scripts - from an Administrator Powershell prompt change the Powershell Execution Policy to remote signed i.e.
Set-ExecutionPolicy RemoteSigned, or from a non-admin Powershell prompt change the Powershell Execution Policy to remote signed i.e. Set-ExecutionPolicy -Scope CurrentUser RemoteSigned - open an Anaconda Prompt and run
conda init powershellwhich will add Conda related startup to a Powershell profile.ps1 somewhere in your user’s profile.
When you run VS Code and either debug a .py or launch a Powershell integrated terminal you should now see a message about “Loading personal and system profiles” and the Conda environment being prefixed on the terminal’s prompt.