211

How can I completely uninstall Anaconda from MacOS Sierra and revert back to the original Python? I have tried using conda-clean -yes but that doesn't work. I also remove the stuff in ~/.bash_profile but it still uses the Anaconda python and I can still run the conda command.

Jordan Baron
  • 3,752
  • 4
  • 15
  • 26
  • 1
    Possible duplicate of [Python Anaconda - How to Safely Uninstall](https://stackoverflow.com/questions/22585235/python-anaconda-how-to-safely-uninstall) – vaer-k Dec 14 '18 at 17:34
  • 8
    haha no way you went to an almost 2 year old post to mark it as duplicate – Jordan Baron Jan 11 '19 at 00:21
  • 3
    how does one uninstall conda if in addition it cannot find the `conda` command but the directory still exists? – Charlie Parker Mar 28 '20 at 20:33
  • see this: https://docs.anaconda.com/anaconda/install/uninstall/ you might have to "macOS 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. " or run `conda install anaconda-clean; anaconda-clean --yes` – Charlie Parker Dec 10 '21 at 16:54

14 Answers14

346

To remove the configs:

conda install anaconda-clean
anaconda-clean --yes

Once the configs are removed you can delete the anaconda install folder, which is usually under your home dir:

rm -rf ~/anaconda3

Also, the anaconda-clean --yes command creates a backup in your home directory of the format ~/.anaconda_backup/<timestamp>. Make sure to delete that one also.


EDIT (v5.2.0): Now if you want to clean all, you will also have to delete the two last lines added to your .bash_profile. They look like:

# added by Anaconda3 5.2.0 installer
export PATH="/Users/ody/anaconda3/bin:$PATH"
Kermit
  • 4,922
  • 4
  • 42
  • 74
jkysam
  • 5,533
  • 1
  • 21
  • 16
  • 12
    Here is an [official link to Anaconda](https://docs.anaconda.com/anaconda/install/uninstall) for more information. – n1k31t4 Nov 07 '17 at 09:39
  • 5
    `rm -rf ~/anaconda2` is for Mac. For Windows–In the Control Panel, choose Add or Remove Programs or Uninstall a program, and then select Python 3.6 (Anaconda) or your version of Python. – Rene Duchamp Dec 05 '17 at 11:50
  • I used this solution for anaconda3, and I observe there is an issue: former path declared in file .bash_profile or .bashrc have not been deleted, therefore when I reinstalled anaconda3 in a different folder and I tred to use `conda` command.. it fails, saying `bash: /home/nathan/anaconda3/bin/conda: No such file or directory` – Nathan Ripert Jan 14 '18 at 11:26
  • 4
    Out of curiosity, what does simple `rm` leave that anaconda-clean --yes gets rid of? – Nathan majicvr.com Apr 10 '18 at 17:46
  • Also, conda 3 backs up your bash profile while installing, so you'll want to merge back in those changes. If you haven't modified your bash profile then you can just copy. – Carlos Bribiescas May 23 '18 at 16:17
  • 20
    Great guide, but with a small typo - the default installation location for Anaconda is the `root` folder, not the home folder. Thus, `rm -rf ~/anaconda3` will fail silenty, i.e., run without actually deleting anything. The correct command is `sudo rm -rf /anaconda3` or `sudo rm -rf /anaconda2` depending on the Anaconda version installed. – DeltaIV Feb 06 '19 at 07:08
  • I had to delete from the /opt folder in the root directory. Somehow it din't get removed when I used rm -rf ~/anaconda. Steps I used are Open Finder. Press Command+Shift+G to open the dialogue box. Input the following in search box : /opt Delete anaconda. – Ankur Feb 05 '20 at 06:08
  • my conda command still works despite following these instructions...why?! – Charlie Parker Mar 27 '20 at 21:23
  • why do I get this ```$ anaconda-clean --yes -bash: anaconda-clean: command not found```? – Charlie Parker Mar 27 '20 at 21:26
  • 5
    I don't know why but just in case someone is suffering like me for some reason it was in this location `/Users/brandBrandoParetoopareto/opt/` so I did `/Users/brandBrandoParetoopareto/opt/miniconda3` – Charlie Parker Mar 27 '20 at 21:35
  • 1
    how do you do the first command if the `conda` command is not found? – Charlie Parker Mar 28 '20 at 20:32
  • I have followed these instructions line by line, but I am still getting an odd behaviour after reinstallation. Anaconda Navigator won't launch spyder and won't recognize that I have a more recent version installed (from terminal, via `conda`), compared to what it says on the GUI. If launched from the command line, I get a `/Users/massimopinto/opt/anaconda3/bin/pythonw: line 3: 4379 Illegal instruction: 4 /Users/massimopinto/opt/anaconda3/python.app/Contents/MacOS/python "$@"` – massimopinto Apr 26 '20 at 08:01
  • if conda is broken, which is usually why you'd want to do this, this may not work if the environment cannot solve. happened to me. the solution @gogasca proposed is better. – jimh May 05 '20 at 19:44
  • @CharlieParker In the current version(at least as of 11/2020), `anaconda-clean` doesn't work. Use `conda clean -a` instead. – Shiva Nov 23 '20 at 14:49
  • Thanks. It's rather funny that you need to install another package to remove anaconda. For me, it is in the opt folder. It was neither from home or root. And yes, don't forget to remove it from the path in the .bash_profile. – Mukherjee Jan 20 '21 at 19:27
  • As @gogasca mentioned, you also need to delete 3 more folders: rm -rf ~/.condarc ~/.conda ~/.continuum – julio May 15 '21 at 10:46
  • I followed your instructions and I still have some files in ~/opt/anaconda3 . What about them? Should I just delete the folder? – pooria Nov 12 '21 at 16:46
  • ‍‍‍‍`Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: /` – Dr.jacky Dec 15 '21 at 15:47
  • I did `which python` to find where the anaconda installation was located – Joey Baruch Apr 05 '22 at 15:20
  • For mac users you also need to remove lines from `.zshrc` `.bash_profile` and folders from `/opt/anaconda3` – Diego Alberto Zapata Häntsch Apr 29 '22 at 19:09
  • You need to activate conda first: "conda activate" and then do "anaconda-clean --yes" – Shivansh Narayan Apr 19 '23 at 17:20
  • If you are getting `‍‍‍‍Solving environment: failed with initial frozen solve.` like @Dr.jacky, first do `conda install anaconda`. It will fix dependencies and you will be able to install `anaconda-clean` – Ernest Jul 31 '23 at 08:21
  • I hope all the people copying and pasting appreciate what a misplaced space will do to their rm -rf commands! – Mark Harrison Aug 25 '23 at 00:23
63

To uninstall Anaconda open a terminal window:

  1. Remove the entire anaconda installation directory:
rm -rf ~/anaconda
  1. Edit ~/.bash_profile and remove the anaconda directory from your PATH environment variable.

Note: You may need to edit .bashrc and/or .profile files instead of .bash_profile

  1. Remove the following hidden files and directories, which may have been created in the home directory:

    • .condarc
    • .conda
    • .continuum

Use:

rm -rf ~/.condarc ~/.conda ~/.continuum
gogasca
  • 9,283
  • 6
  • 80
  • 125
  • 6
    Note to newbies: may need to edit .bashrc and/or .profile instead – Nathan majicvr.com Apr 12 '18 at 23:20
  • 3
    As DeltaIV stated above; this will fail. At least did so for me: "Great guide, but with a small typo - the default installation location for Anaconda is the root folder, not the home folder. Thus, rm -rf ~/anaconda3 will fail silenty, i.e., run without actually deleting anything. The correct command is sudo rm -rf /anaconda3 or sudo rm -rf /anaconda2 depending on the Anaconda version installed." – Oeyvind Sep 04 '19 at 13:33
  • I needed to remove coda-related entries in ~/.bash_profile I replaced the coda stuff in ~/.bash_profile with: # Pyenv initialization if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)" fi – githeko May 30 '23 at 20:44
17

In my case (Mac High Sierra) it was installed at ~/opt/anaconda3.

https://docs.anaconda.com/anaconda/install/uninstall/

Laknath
  • 470
  • 5
  • 5
17

MacOS Big Sur and MacOS High Sierra differ: the anaconda folder is ~/opt/anaconda3 instead of ~/anaconda3, according to the comment by jmgonet and answer by Laknath.

Install the cleaner

me@host:~$ conda install anaconda-clean

Activate the 'base' virtual environment

me@host:~$ source ~/anaconda3/bin/activate

Run the cleaner

(base) me@host:~$ anaconda-clean --yes

Deactivate the 'base' virtual environment

(base) me@host:~$ conda deactivate

Remove the files

me@host:~$ rm -rf ~/anaconda3
me@host:~$ rm -rf ~/.anaconda_backup

Delete lines added by conda from environment file(s)

Open the .bashrc file (and/or .profile and/or .bash_profile)

nano .bashrc

Search for conda in the .bashrc file (opened in the nano editor):

  1. press CTRL+W
  2. type conda
  3. press ENTER

Remove everything that looks like it has been added by/for anaconda:

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

This was done on Ubuntu 18.04 and will probably also work on MacOS.

Emil Carpenter
  • 1,163
  • 10
  • 19
13

The following line doesn't work?

rm -rf ~/anaconda3 

You should know where your anaconda3(or anaconda1, anaconda2) is installed. So write

which anaconda

output

output: somewhere

Now use that somewhere and run:

rm -rf somewhere 
4

Open the terminal and remove your entire Anaconda directory, which will have a name such as “anaconda2” or “anaconda3”, by entering the following command: rm -rf ~/anaconda3. Then remove conda with command conda uninstall see https://conda.io/docs/commands/conda-uninstall.html.

ilam engl
  • 1,310
  • 1
  • 9
  • 22
Monika Bozhinova
  • 294
  • 3
  • 16
  • 1
    When running `conda uninstall` I get `CondaValueError: Value error: no package names supplied, try "conda remove -h" for more details` – Jordan Baron Feb 12 '17 at 00:24
  • 1
    write echo $PATH in your terminal to check if there is some reference to anaconda, if there is use export PATH="/path/you/want/to/keep" – Monika Bozhinova Feb 12 '17 at 00:40
3

None of these solutions worked for me. Turns out I had to remove all the hidden files that you can reveal with ls -a My .zshrc file had some anaconda references in it that needed to be deleted

Некто
  • 1,730
  • 10
  • 17
2

This has worked for me:

conda remove --all --prefix /Users/username/anaconda/bin/python

then also remove from $PATH in .bash_profile

evagreen
  • 21
  • 3
  • 1
    This is a nice idea, but according to the documentation, this is meant for removal of conda environments. Here is the way Anaconda suggests: [using `anaconda-clean`](https://docs.anaconda.com/anaconda/install/uninstall) – n1k31t4 Nov 07 '17 at 09:36
2

This is one more place that anaconda had an entry that was breaking my python install after removing Anaconda. Hoping this helps someone else.

If you are using yarn, I found this entry in my .yarn.rc file in ~/"username"

python "/Users/someone/anaconda3/bin/python3"

removing this line fixed one last place needed for complete removal. I am not sure how that entry was added but it helped

jstamis
  • 56
  • 1
2

After performing the very helpful suggestions from both spicyramen & jkysam without immediate success, a simple restart of my Mac was needed to make the system recognize the changes. Hope this helps someone!

riot
  • 307
  • 3
  • 7
0

Adding export PATH="/Users/<username>/anaconda/bin:$PATH" (or export PATH="/Users/<username>/anaconda3/bin:$PATH" if you have anaconda 3) to my ~/.bash_profile file, fixed this issue for me.

StOchastiC_
  • 133
  • 8
  • I think you misunderstand the question. The question is how to _uninstall_ Anaconda, not fix it. What you're suggesting here is a fix for keeping/installing Anaconda, not removing it – Abe Mar 19 '19 at 22:05
0

unset your ~/.bash_profile's PYTHONPATH and PYTHONHOME

(ps: when you debug Arduino, you may have set those vars. It would confuse the conda's env)

ghostyusheng
  • 157
  • 1
  • 4
0

After running the uninstall commands for Anaconda, miniconda3 was still showing up in the path. Ultimately this is what worked for me:

With terminal open (I use zsh)

open ~/.zshrc

Delete the contents, save, exit terminal, and reopen.

This solved the eternal conda issue for me, finally!

MaryK39
  • 29
  • 3
-4

The official instructions seem to be here: https://docs.anaconda.com/anaconda/install/uninstall/

but if you like me that didn't work for some reason and for some reason your conda was installed somewhere else with telling you do this:

rm -rf ~/opt

I have no idea why it was saved there but that's what did it for me.


This was useful to me in fixing my conda installation (if that is the reason you are uninstalling it in the first place like me): https://stackoverflow.com/a/60902863/1601580 that ended up fixing it for me. Not sure why conda was acting weird in the first place or installing things wrongly in the first place though...

Charlie Parker
  • 5,884
  • 57
  • 198
  • 323