How can I run powershell.exe with Anaconda in new windows terminal profiles?
I realize I'm late of some years but I had a similar problem and stranded up here looking for an answer. So, I'm hoping that this is useful for people like me in the future.
After some time tinkering I generated an Anaconda profile:
- copy paste an existing profile
- generate guid here
- open C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)
- right click on Anaconda Powershell Prompt (Miniconda3) and go to Properties
- copy the entire content of the
target
field and paste it on the fieldcommandline
(make sure the field iscommandline
and notsource
) - escape all the
\
characters (\
-->\\
) - Change the name field
You should have something like this
{ "guid": "{generated guid}", "hidden": false, "name": "Anaconda", "commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command & 'C:\\ProgramData\\Miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate 'C:\\ProgramData\\Miniconda3'" },
As a nice sidenote, you can also create a profile to directly launch an Ipython session or a jupyter notebook.As you may have noticed, lo launch anaconda in the commandline
field we are just launching powershell.exe
, and then telling the powershell instance to execute a -Command
, which is the subsequent string.Were you to add a ; ipython
to the command, you would launch an ipython session.
Copy-paste the settings for cmd from above.
Go to "C:\Users\Username\AppData\Roaming\Microsoft\Windows\StartMenu\Programs\Anaconda3 (64-bit)"
Right-click on "Anaconda Prompt (Anaconda3)"
Copy the content from the target field and paste it on the field commandline
Mine is
%windir%\System32\cmd.exe "/K" C:\bin\Anaconda3\Scripts\activate.bat C:\bin\Anaconda3
Replace \ with \
Thanks to the above answer by Marco Necci, this is a more clear version with cmd and anaconda
"commandline" : "%windir%\\System32\\cmd.exe /K C:\\bin\\Anaconda3\\Scripts\\activate.bat C:\\bin\\Anaconda3"
Building upon Navaneeth M et al, I contribute a command line which includes the default Anaconda location using USERPROFILE environment variable, specifying non-default Anaconda env (fastai), starting directory and color scheme.
"commandline": "%windir%\\System32\\cmd.exe /K %USERPROFILE%\\Anaconda3\\Scripts\\activate.bat fastai","colorscheme": "Solarized Light","startingDirectory": "c:\\sw",
Pro Tip: Use keybindings
to add a hotkey which opens a new tab in the specified project directory. For example, use ctrl-b to open a new Anaconda tab in just the right place.
"keybindings": [ { "keys": [ "ctrl+b" ], "command": { "action": "newTab", "profile": "Anaconda", "startingDirectory": "c:\\sw\\myproject\\myprojectdirectory" } }]