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?

2
  • 8
    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. Sep 29, 2020 at 1: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, 2022 at 11:47

4 Answers 4

101

Run this on the terminal:

$ conda config --set changeps1 False

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

5
27

Add:

changeps1: False

to your .condarc file.

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

17

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.

3
  • ONce you have done this, how do you get back a terminal with (base) ?
    – Bram
    Nov 6, 2019 at 22:45
  • 2
    Hey @Bram, that's simple, just run conda activate, it will activate the base environment! Cheers
    – saza
    Nov 7, 2019 at 22:14
  • 1
    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 3 at 0: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*//' )
2
  • 1
    While this solution may work, it treats the symptoms rather than the cause. I'm wondering why it was marked the accepted answer.
    – normanius
    Oct 21, 2022 at 18:10
  • I love how it only filters out base. What if I switch branches?
    – emmeowzing
    Mar 30 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.