Removing Anaconda from macOS Big Sur: A Rephrased Guide

Open the Terminal.app or iTerm2 terminal application, and then
remove
your entire
Anaconda
directory, which has a name such as
anaconda2
, anaconda3, or ~/opt. Enter rm -rf ~/anaconda3 to
remove
the directory. If you’ve
deleted
the main program and the main folders (which I repeat above), I would say you’re good.


Question:

I have a query regarding
uninstalling Anaconda
on macOS Big Sur. I would appreciate it if someone could assist me in finding a solution. Despite following the instructions provided on the official website (https://docs.anaconda.com/anaconda/install/uninstall/) and referring to additional guides, I still couldn’t achieve my objective. Here are the steps I took:

1) conda install anaconda-clean
2) anaconda-clean --yes
3) rm -rf ~/.condarc ~/.conda ~/.continuum
4) rm -rf ~/anaconda
5) conda remove -n myenv scipy
                         *PackagesNotFoundError
6) conda remove scipy
7) conda remove scipy curl
                         *PackagesNotFoundError
8) rm -rf ~/anaconda3
9) rm -rf ~/.anaconda_backup
10) export PATH=”/Users/MYUSERNAME/anaconda3/bin:$PATH

  1. I discarded the application by throwing it in the trash and then emptying it.

I’m uncertain if I took the correct actions, so perhaps you could offer me some guidance. Nonetheless, I haven’t removed everything as I still have a directory located at /opt path, specifically /opt/anaconda3. I am confident that there was another folder in /user/MYNAME, but I believe I have deleted it since it’s no longer visible, even among the hidden directories.

Then, if I run

conda list

There are still numerous other packages that remain accessible.

# packages in environment at /opt/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py37_0  
anaconda-clean            1.1.0            py37hecd8cb5_1  
anaconda-client           1.7.2                    py37_0  
[...] 
zlib                      1.2.11               h1de35cc_3  
zstd                      1.4.5                h41d2c2f_0

Furthermore, I still observe conda running in my terminal, indicated by the presence of “(base)” every time I open it. Here is an example:

(base) MYUSERNAME@MacBook ~ %

I include the content from .bash_profil as well, as it could be connected to “the issue with my terminal (base)”.

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

My intention was to remove all the packages and files associated with Anaconda.

Thanks in advance


Solution 1:

This scenario presents a typical issue where installers and applications scatter files and debris across the filesystem, requiring users to run numerous scripts that change on a weekly basis with each version upgrade. As a result, recovering the 5 GB of space should be a straightforward process, without concerns over residual stub files and mostly empty configuration files.

Launch the Terminal.app or the
iTerm2 terminal
application, and proceed to delete the entire
Anaconda directory
folder. This folder may have a name like anaconda2, anaconda3, or ~/opt. Use the command rm -rf ~/anaconda3 to delete the directory.

Once you have deleted the main program and folders that were mentioned previously, it is safe to assume that you are in good shape. Make sure to set up Time Machine to back up your files in the future, so that if you encounter any issues during the installation of similar tool chains and environments, you can easily revert back to the previous backup. Keep in mind that cleaning up hundreds of files won’t yield any benefits unless there is a large file present. Moreover, there are other tools available that can help you locate and clean up folders and large files simultaneously.


In the rare case that you encounter a problem due to residual files, the process of deleting and reinstalling a Mac, along with restoring your documents and applications, is simpler and quicker than having to reconstruct what
anaconda installed
and meticulously reverse every remaining trace in the file system.

Furthermore, performing

rm

incorrectly can result in unintentionally deleting more content than intended.

  • Is there a way to enable the ‘rm’ command to move files to the trash can?

Instead of using

rm

, it is safer to use

open

and be sure to acknowledge and remove any flags such as -rf that are passed to rm. My suggestion is to open the folders using the command line instead of deleting them if you are unsure about the syntax of the commands you are copying and pasting into the terminal. The authors of those guides assume that you are familiar with the commands and will not hold them responsible if you make a mistake and delete your home folder along with all your pictures and documents.


Solution 2:


The problem arises from the assumption made by the uninstall instructions that
installed anaconda
is only installed for an individual user, when in fact it has been installed for all users on the machine.

The installation directory is specified as /opt/anaconda, whereas the uninstall instructions assume that it is located in ~/anaconda.

To uninstall for a single user, you only need to follow the initial 4 steps (and possibly skip step 3 if step 2 already covers it), along with modifying your shell startup files.

However, it is important to note that step 4 requires the use of the directory where anaconda is installed, which may not always be “~/anaconda”. In your specific case, it is “/opt/anaconda”. The correct path can be determined by executing ”

conda info

” before proceeding with the removal process. The directory to be removed can be identified from the entry for the base environment.

To eliminate the entries from your shell, it is important to point out that your step 10 does not align with the instructions provided in the uninstall document. The document suggests locating a line similar to that and making edits to remove it. However, it fails to address the typical updates made to .bash_profile. You will need to remove the section that begins with ”

# >>> conda initialize >>>

” and concludes with ”

# <<< conda initialize <<<

“.

Based on my understanding, I believe the steps would be as follows, although I haven’t tested them yet since I require conda.

  1. Execute the command

    conda info

    and make a record of the underlying environment.
  2. conda
    install anaconda
    -clean
  3. anaconda-clean –yes
  4. I believe that running the command “rm -rf ~/.condarc ~/.conda” should suffice.
  5. Delete the directory with the value obtained in step 1 using the “rm -rf” command.
  6. Make modifications to your shell startup files to eliminate any entries that modify your path for conda, including the segments within the conda initialization section.
  7. After conducting all tests, eliminate the backup directory mentioned in the documentation.

Frequently Asked Questions