conda init powershell has no effect

Viewed 515

I installed Anaconda3 on my Windows Laptop and tried to make the conda activate command available in powershell so that I can use the conda env in VS Code for a Jupyter Notebook. But the problem is this:

  1. Added Conda to the Environment-PATH
  2. I executed conda init powershell in the conda prompt and closed it afterwars
  3. opened powershell and executed set-executionpolicy remotesigned
  4. then i restarted the computer
  5. eventhough it should be working at this point I still get the following message when executing conda activate base inside powershell:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. If using 'conda activate' from a batch script, change your invocation to 'CALL conda.bat activate'. To initialize your shell, run conda init <SHELL_NAME> Currently supported shells are:

  • bash
  • cmd.exe
  • fish
  • tcsh
  • xonsh
  • zsh
  • powershell

See 'conda init --help' for more information and options. IMPORTANT: You may need to close and restart your shell after running 'conda init'.

1 Answers

I noticed that your powershell could execute conda init successfully.

2.I executed conda init powershell in the conda prompt and closed it afterwars

Normally this command will edit this account's powershell startup config file, which locates in C:\Users\[YOUR_ACCOUNT_NAME]\Documents\WindowsPowerShell\profile.ps1. Please make sure that the edited file include codes like this in your personal folder:

#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
(& "C:\ProgramData\Miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
#endregion

Sometimes the code page that powershell is using may cause jumbled characters when your account name includes non-ascii characters, resulting in editing the profile.ps1 in the jumbled path. Just copy it into your real account path as shown above.

Related