I tried to make a profile in Windows terminal which would emulate the behavior of the Anaconda Powershell prompt. When I right-click > properties on the Anaconda Powershell Prompt shortcut on my windows machine the "Target" field shows the following:
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\me\miniconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\me\miniconda3' "
On cmd
, %WINDIR%
evaluates to C:\Windows
. So I created a new Windows Terminal and copied the contents of the "Target" field into the commandline
parameter in the settings.json
file:
{
"commandline": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy ByPass -NoExit -Command '& C:\\Users\\amine\\Miniconda3\\shell\\condabin\\conda-hook.ps1 ; conda activate C:\\Users\\amine\\Miniconda3'",
"hidden": false,
"guid":"{236722dd-af73-416e-b467-67bca56e114d}",
"name": "Anaconda powershell prompt",
"font": {"size": 10}
}
Unfortunately, when I check the $env:path
associated with this profile, it still does not contain the Miniconda related paths. Furthermore, when I run conda
I get that it is an unknown cmdlet. The $env:path
is otherwise identical with a regular powershell prompt.
Why does my custom profile not a activate Anaconda in Windows Terminal? How can I get it to work?
After having a look at this comment, I realized that the string I was passing to the -command
parameter may have been incorrect. I changed commandline
in the Windows Terminal profile to the following:
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy ByPass -NoExit -Command & 'C:\\Users\\me\\Miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate C:\\Users\\me\\Miniconda3"
Then it worked fine.