How to Prevent Ubuntu Terminal from Starting with the Anaconda Base Environment

In this blog post, we’ll explore a common issue faced by data scientists and developers using the Anaconda distribution on Ubuntu: the terminal starting with the Anaconda base environment. We’ll walk through the steps to correct this behavior, ensuring a smoother workflow for your data science projects.

How to Prevent Ubuntu Terminal from Starting with the Anaconda Base Environment

In this blog post, we’ll explore a common issue faced by data scientists and developers using the Anaconda distribution on Ubuntu: the terminal starting with the Anaconda base environment. We’ll walk through the steps to correct this behavior, ensuring a smoother workflow for your data science projects.

Table of Contents

Understanding the Issue

When you install Anaconda on Ubuntu, it modifies the .bashrc file to activate the base environment each time a new terminal session is started. While this can be convenient for some, it can also lead to confusion and unwanted behavior for others. If you’re among those who prefer to manually activate your Anaconda environments, read on to learn how to prevent the terminal from automatically starting with the Anaconda base environment.

Step-by-Step Solution

Here’s a step-by-step guide to correct this behavior:

  1. Open the .bashrc file

    Open your terminal and type the following command to open the .bashrc file in a text editor:

    nano ~/.bashrc
    
  2. Locate the Anaconda script

    Scroll down to the end of the file and locate the following lines:

    # added by Anaconda3 installer
    # __conda_setup="$('/home/username/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
    # if [ $? -eq 0 ]; then
    #     eval "$__conda_setup"
    # else
    #     if [ -f "/home/username/anaconda3/etc/profile.d/conda.sh" ]; then
    #         . "/home/username/anaconda3/etc/profile.d/conda.sh"
    #     else
    #         export PATH="/home/username/anaconda3/bin:$PATH"
    #     fi
    # fi
    # unset __conda_setup
    
  3. Comment out the Anaconda script

    Comment out the lines related to Anaconda by adding a # at the beginning of each line. This will prevent the script from running when you start a new terminal session.

  4. Save and exit

    Press Ctrl+X to exit, then Y to save the changes, and finally Enter to confirm.

Verifying the Solution

To verify that the changes have taken effect, close your terminal and open a new one. The Anaconda base environment should no longer be activated by default. You can confirm this by typing:

conda info --envs

The asterisk (*) should be next to the base environment, indicating that it is not currently active.

Conclusion

In this post, we’ve walked through the steps to prevent the Ubuntu terminal from automatically starting with the Anaconda base environment. This simple tweak can help streamline your workflow and reduce confusion when working with multiple Anaconda environments. Remember, you can still manually activate the base environment at any time by typing conda activate base.

We hope this guide has been helpful. Stay tuned for more tips and tricks to optimize your data science workflow on Ubuntu!


Keywords: Ubuntu, Anaconda, Terminal, Data Science, Environment, Workflow, .bashrc, Conda, Base Environment, Anaconda3, Ubuntu Terminal, Data Scientists, Anaconda Distribution, Conda Environments, Conda Activate Base, Conda Info –envs, Anaconda Script, Anaconda Installer


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.