How to change the path of conda base

24,706

Solution 1

  1. Prepend condabin/conda into PATH. Write the following settings into your shell init files. ~/.bash_profile, ~/.bashrc for Bash, ~/.zshrc for ZSH.

    export PATH="/home/user/miniconda3/condabin:$PATH"
    

    Reopen a new shell. Check the result of which -a conda. Make sure the conda from /home/user/miniconda3/condabin takes precedence over other conda executables.

  2. Cleanup and redo conda init.

    Open your shell init files. Remove the following content,

    # >>> conda initialize >>>
    ...
    # <<< conda initialize <<<
    

    Save the configuration files.

    Reopen a new shell, type /home/user/miniconda3/condabin/conda init once.

    Done.


Update: But I still recommend you use the Anaconda already installed on your system. There's no need to install two conda packages.

Because conda is a python manger and a package manager. You can create environments with any version of Python you want with command conda.

The only difference between an Anaconda and a Miniconda installation is that, the "base" environment where conda is installed from Anaconda, is bundled with more pre-installed packages than the "base" env from Miniconda.

Configuring conda to store environments under your home directory is enough.

conda config --prepend pkgs_dirs /home/user/.conda/pkgs
conda config --prepend envs_dirs /home/user/.conda/envs

All you need is the execution permission of the command conda, the environments and pkg caches are stored under your home folder.

Solution 2

When one installs different distributions of Anaconda, the package shell scripts change the base environment. (That was what happened when I installed Miniforge3 to experiment with python for M1 Silicon)

Try to See: echo $PATH and one can see paths to active base environment but those paths wont be on ~/.bash_profile PATH

To change default/base environment follow below steps:

On Mac:

  1. Open your /Users/your username/.zshrc (in a TextEditor)

  2. There would be the paths to current base environment. Replace the path with the one which should be the default one for your case.

  3. Close and Reopen Terminal.

  4. Run 'conda info --envs' and the base env would be changed to path mentioned in ~/.zshrc

Share:
24,706
geosciz
Author by

geosciz

Updated on July 09, 2022

Comments

  • geosciz
    geosciz almost 2 years

    I am a Linux cluster user. While I installed a version of miniconda, the cluster had its own version of anaconda. When I do

    conda info --envs
    

    the output is

    # conda environments:
    #
             /home/user/miniconda3/envs/my_envs
    base  *  /usr/local/anaconda
    

    This type of settings may sometimes result in the "permission denied" error. Is there a method to change the path of the base environment to /home/user/miniconda3?