60

When using anaconda (install for python), when I switch to the virtual env with this:

source activate my_env

It changes my prompt and adds (my_env) at the start of my PS1.

I've tried adding export VIRTUAL_ENV_DISABLE_PROMPT=1 to my bashrc, but it did not help.

Any idea?

DevShark
  • 8,558
  • 9
  • 32
  • 56
  • 6
    This is deeply worrying. If anaconda thinks it has the right to edit `.bash_profile` in a way which changes the prompt, what else does it (mistakenly) think it has the right to do? Turns out, it also adds to the beginning of `PATH` so that, for example, `curl` is redefined. Ouch! I’m treating this as malware. – Adam Chalcraft Sep 29 '20 at 01:44
  • 2
    @AdamChalcraft This seems to be an overreaction. Anaconda is a well-established and widely used tool, and this is a normally very useful feature. If the user loses track of which environment they're in, they'll likely get strange errors and broken dependencies. I also don't think it's a surprise that a tool whose purpose is to create isolated and self-consistent virtual environments within your system will redefine some of your important exeutables - how else would it work? – Neinstein Jun 10 '22 at 11:47

4 Answers4

98

Run this on the terminal:

$ conda config --set changeps1 False

http://conda.pydata.org/docs/config.html#change-command-prompt-changeps1

rajats105
  • 1,081
  • 8
  • 2
  • 3
    Any idea on how to do that just for the base environment? (https://stackoverflow.com/a/54725966/1273751) – Homero Esmeraldo Mar 13 '19 at 22:24
  • https://stackoverflow.com/questions/55171696/how-to-remove-base-from-terminal-prompt-after-updating-conda – Kyle Barron May 06 '20 at 19:06
  • Is there any way to make this same change but for PS2 env variable? `conda config --set changeps2 False` did not work :( – Ian Tait Dec 28 '21 at 00:17
  • Just in case you stumbled upon this because of an issue with **posh-git**: https://stackoverflow.com/a/70527216/5561649 – LoneCodeRanger Nov 02 '22 at 23:08
  • This didn't work for me. But used answer from saza, which worked: conda config --set auto_activate_base False – n13 Sep 03 '23 at 00:56
26

Add:

changeps1: False

to your .condarc file.

http://conda.pydata.org/docs/config.html#change-command-prompt-changeps1

Adam
  • 938
  • 1
  • 8
  • 22
14

I've had a slightly different, but related problem: how to avoid the base env to be activated by default for every terminal window. Solution:

conda config --set auto_activate_base False

Note: this only works if you have run conda init first.

saza
  • 460
  • 6
  • 7
  • ONce you have done this, how do you get back a terminal with (base) ? – Bram Nov 06 '19 at 22:45
  • 2
    Hey @Bram, that's simple, just run `conda activate`, it will activate the base environment! Cheers – saza Nov 07 '19 at 22:14
  • Correct answer - I use terminal a lot and often for things not related to python so I can't have conda intrude everywhere. But when I use it, I want to see it. This solution does that. – n13 Sep 03 '23 at 00:55
5

If you are like me, you like the non-default environment to show up if you have activated it, but don't want to clutter up your prompt in other cases - (e.g. you happen to use bash for reasons having nothing to do with python)

Place the following excerpt in your ~/.bash_profile right after the section managed by conda:

# ahj - remove the default Python environment artifact "(base)" from prompt
PS1=$(echo "$PS1" | perl -pe 's/^\(base\)\s*//' )