Question
Answer and Explanation
When you install Anaconda, it often sets up its base environment to activate automatically when you open a new terminal. This can be convenient for many users, but if you want to use your system's regular terminal instead of the Anaconda base environment, there are several ways to achieve this. Here's a breakdown of common solutions:
1. Deactivate Anaconda base Environment:
- The simplest way to temporarily use your regular terminal is to deactivate the Anaconda base environment in your current terminal session. You can do this by running the command:
conda deactivate
- This command will remove the Anaconda environment from your terminal session, and you will then be using your system’s default environment. However, it is a temporary solution and you will have to do it every time you open the terminal.
2. Prevent Automatic Activation of the Base Environment:
- To prevent Anaconda’s base environment from activating automatically every time you open a new terminal, you can configure the settings. Use the following command:
conda config --set auto_activate_base false
- This command will disable the automatic activation of the base environment for all new terminals. After this change, you will be using your system's regular environment until you specifically activate an Anaconda environment with, for example, conda activate base
.
3. Modify Shell Configuration Files:
- Sometimes, changes by the conda config
command don’t fully resolve the issue due to some system-specific configuration files. In this case, you will have to manually modify your shell configuration files.
- Depending on your system, you may need to edit files such as .bashrc
, .zshrc
, or .profile
in your home directory, usually by using a text editor like nano, vim or VS Code:
nano ~/.bashrc
(for Bash)
- Look for lines that initialize conda. They might look something like:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
eval "$(conda shell.bash hook)"
# <<< conda initialize <<<
- You can either comment out those lines (by adding a # at the start of each line) or delete them. Save the file and start a new terminal session. The conda environment will not be activated automatically.
4. Using conda environments:
- If you want to use an anaconda environment other than base, you can always create a new environment and activate it when you need it. For example, to create a Python 3.9 environment called myenv
, you would run:
conda create -n myenv python=3.9
- To activate that environment, you would run:
conda activate myenv
By following these steps, you can choose whether or not the Anaconda base environment is active in your terminal, and you will have the freedom of using other environments for different use cases. Always ensure that you have the proper configuration for the tools and software you need.