8

After installing Anaconda for python. (base) appears before the directory in Powershell. How to remove it?

enter image description here

DavidPostill
  • 162,382
Krishna
  • 83

4 Answers4

16

The (base) notatation is there to tell you which virtual environment that you are on. This is very useful when you are using different environments on the same system.

If you are not doing anything in python, you can run conda deactivate until you want need to use the python environment. You can stop it auto activating with conda config --set auto_activate_base false

Randomhero
  • 1,543
2

Obviously your prompt function was modified, presumably by one of the profiles.

View the definition with:

(Get-Command prompt).Definition

And see if you can evaluate the origin by viewing the possible profile files:

$PROFILE|Format-List -Force

You could also let powershell do the work:

## Q:\Test\2019\07\21\SU_1462281.ps1

$PROFILE.PSObject.Properties | 
  Where-Object Membertype -eq Noteproperty | ForEach-Object{
    if (Test-Path $_.Value){
      Select-String -Path $_.Value -Pattern 'function\s*prompt'
    }
  }
#

Sample output, which contains found Path:LineNumber:Line

C:\Users\LotPings\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:69:function Prompt {
LotPings
  • 7,391
0

The script that triggers conda whenever a PowerShell window is started is usually named profile.ps1 and can be located in

C:\users\userName\OneDrive - xxxx\Documents\WindowsPowerShell\profile.ps1

Note, quite probably you will find the file in following path instead, it will depend on your computer configuration:

C:\users\userName\Documents\WindowsPowerShell\profile.ps1

Inside this file you will find following code:

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

To fix it, add a number sign (# ) to the uncommented line is commented as the rest of the lines, save it (Every line from the snippet should start by #). After you restart a PowerShell window you will no longer see that conda was automatically started.

0

I removed it by opening this file:

C:\Users\<XXX>\anaconda3\shell\condabin\conda-hook.ps1

Change this line from $True to $False:

$CondaModuleArgs = @{ChangePs1 = $True}
laviex
  • 121