Table of Contents
Run Anaconda Script in Powershell to Error
I met this error when opening PowerShell after running:
conda init powershell
PowerShell tried to load my profile script, but blocked it because of the current execution policy:
+ . <<<< 'C:\Users\user\Documents\WindowsPowerShell\profile.ps1'
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
conda init powershell modifies the PowerShell profile so that Conda can initialize automatically. If PowerShell is not allowed to run profile scripts, Conda cannot finish loading and the shell reports a PSSecurityException.
A safer fix is to allow locally created scripts for the current user:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Then close PowerShell and open it again.
If you still want to use the original broader setting that solved the issue for me, run:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
You can check the active policy with:
Get-ExecutionPolicy -List
For most local Conda setups, changing only CurrentUser is enough and avoids changing the policy for the whole machine.
