304

I installed Python Anaconda on Mac (OS Mavericks). I wanted to revert to the default version of Python on my Mac. What's the best way to do this? Should I delete the ~/anaconda directory? Any other changes required?

Currently when I run which python I get this path:

/Users/username/anaconda/bin/python

Luboš Turek
  • 6,273
  • 9
  • 40
  • 50
william tell
  • 4,352
  • 6
  • 23
  • 27
  • 9
    @PeterWang conda can't deploy on AWS, I am having a lot of trouble getting it to work and also can't use pip/virtualenv when I have anaconda installed... – ajl123 Feb 11 '16 at 05:38
  • 7
    Anaconda actually have a guide for uninstalling http://conda.pydata.org/docs/install/full.html#os-x-anaconda-install – Dials Mavis Feb 12 '16 at 20:34
  • 9
    @PeterWang Anaconda overrites my default mac interpreter which by default is used by pip for module installs. I wasted about an hour of my time today trying to figure out why my modules weren't being loaded. – Jolly1234 Feb 27 '16 at 23:56
  • 1
    Does this answer your question? [How to uninstall Anaconda completely from macOS](https://stackoverflow.com/questions/42182706/how-to-uninstall-anaconda-completely-from-macos) – AMC Jan 10 '20 at 01:54
  • 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:34

19 Answers19

294

From the docs:

To uninstall Anaconda open a terminal window and remove the entire anaconda install directory: rm -rf ~/anaconda. You may also edit ~/.bash_profile and remove the anaconda directory from your PATH environment variable, and remove the hidden .condarc file and .conda and .continuum directories which may have been created in the home directory with rm -rf ~/.condarc ~/.conda ~/.continuum.

Further notes:

  • Python3 installs may use a ~/anaconda3 dir instead of ~/anaconda.
  • You might also have a ~/.anaconda hidden directory that may be removed.
  • Depending on how you installed, it is possible that the PATH is modified in one of your runcom files, and not in your shell profile. So, for example if you are using bash, be sure to check your ~/.bashrc if you don't find the PATH modified in ~/.bash_profile.
vaer-k
  • 10,923
  • 11
  • 42
  • 59
152

The anaconda installer adds a line in your ~/.bash_profile script that prepends the anaconda bin directory to your $PATH environment variable. Deleting the anaconda directory should be all you need to do, but it's good housekeeping to remove this line from your setup script too.

mwaskom
  • 46,693
  • 16
  • 125
  • 127
  • When I go to remove the anaconda directory I get some warnings: override rwxr-xr-x root/staff for anaconda//bin/cftp - Okay to proceed with these? Also will python then automatically revert to the system install after removing anaconda and making bash changes? – william tell Mar 23 '14 at 00:04
  • Yep that should be fine. See [here](http://docs.continuum.io/anaconda/faq.html#uninstall-anaconda) for the official word on this. – mwaskom Mar 24 '14 at 18:15
  • 24
    There may also be `~/.continuum` and `~/.spyder2` and `~/.cache` and `~/.distlib` and `~/.matplotlib` directories, which you should also delete. – tadasajon May 14 '14 at 18:00
  • 10
    In your home directory (`~/`), there is also a backup file created by anaconda: `.bash_profile-anaconda.bak`, which backup your original `.bash_profile`. You can compare that file with your current `.bash_profile`, and after that, you can safely remove the `.bash_profile-anaconda.bak` file. – YaOzI Jul 16 '14 at 05:03
  • 10
    I found anaconda's `$PATH` appending line in `~/.bashrc`, fyi. – TheGrimmScientist Sep 07 '15 at 18:41
  • removing .conda, .condarc, ~/anaconda2 and removing the addition to .bashrc worked for me to uninstall anaconda2 so far... – alpha_989 Nov 22 '17 at 19:24
  • is adding it to the trash bin considered deleting – JobHunter69 Apr 20 '18 at 19:55
  • 1
    Where do I find his file bash file on windows? – Mohit Motwani Feb 07 '19 at 04:05
  • 1
    @MohitMotwani on windows there is no bash file The steps are totally different for windows. [see here](https://docs.anaconda.com/anaconda/install/uninstall/) – Tejas Shetty Aug 26 '19 at 16:18
133

Package "anaconda clean", available from Anaconda platform, should uninstall safely.

conda activate your_conda_env  # activate your conda environment
conda install anaconda-clean   # install the package anaconda clean
anaconda-clean --yes           # clean all anaconda related files and directories 

rm -rf ~/anaconda3             # removes the entire anaconda directory

rm -rf ~/.anaconda_backup       # anaconda clean creates a back_up of files/dirs, remove it 
                                # (conda list; cmd shouldn't respond after the clean up)

Refer: https://docs.anaconda.com/anaconda/install/uninstall for more details.

Note: Also, you may want to edit .bashrc (or .bash_profile) & remove the conda path in $PATH environment variable for full proper clean-up

Surya
  • 11,002
  • 4
  • 57
  • 39
  • 1
    I had a second installation of anaconda via brew. To uninstall it I needed to call `brew cask uninstall anaconda` in addition. – asmaier May 02 '18 at 09:32
  • 1
    Using this answer I lost my PATH and had to reset it. Wasn't a big issue seeing as mine's a brand new machine with no customised PATH (yet)... but wanted to comment in order to warn anyone who risks losing some import PATH configuration. – olisteadman Dec 17 '18 at 13:55
25

Removing the Anaconda directory helps, but I don't think that's a good idea as you might need to use anaconda sometimes in near future. So, as suggested by mwaskom, anaconda installer automatically adds PATH variable which points to anaconda/bin directory in the ~/.bashrc file.

It looks like this

PATH="/home/linuxsagar/anaconda3/bin:$PATH

So, just comment out the line (add # in the beginning of the line). Then reload the ~/.bashrc file executing source ~/.bashrc

Now, verify the changes executing which python in the new terminal.

Luboš Turek
  • 6,273
  • 9
  • 40
  • 50
sgiri
  • 691
  • 12
  • 28
  • 1
    @XiaodongQi have you tried `$which python` in new terminal window after `$source ~/.bashrc` ? – sgiri Nov 24 '16 at 05:36
  • I did check the path of python, it was still pointing to the anaconda directory. Then I found a workaround to solve this problem. Besides what you recommended, I also added a line `export PATH=/usr/bin:$PATH` in the `~/.bashrc` file. It works afterward! Thanks! – Xiaodong Qi Nov 24 '16 at 06:41
  • Where do I find his file bash file on windows? – Mohit Motwani Feb 07 '19 at 04:04
15
rm -rf ~/anaconda

It was pretty easy. It switched my pointer to Python: https://docs.continuum.io/anaconda/install#os-x-uninstall

Zoe
  • 27,060
  • 21
  • 118
  • 148
Jonathan
  • 469
  • 6
  • 13
10

If you're uninstalling Anaconda to be able to use the base Python installation in the system, you could temporarily disable the path by following these steps and not uninstalling Anaconda.

Go to your home directory. Just a cd command will do.

Edit the file .bashrc.

Look for something like export PATH="/home/ubuntu/anaconda3/bin:$PATH" in the file.

Put a # at the beginning to comment it from the script.

#export PATH="/home/ubuntu/anaconda3/bin:$PATH"

Open a new terminal and you should be running the base python installation. This works on Linux systems. Should work on Mac too.

jp0d
  • 170
  • 2
  • 10
  • for some reason, I had to restart. Don't think that's really necessary, but it worked w/o uninstalling anything. – Mike S. Mar 31 '17 at 19:10
  • 1
    yeah.. I don't think it's necessary! Just opening a new shell should do the job I reckon! – jp0d Apr 08 '17 at 11:15
10

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:

  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

Emil Carpenter
  • 1,163
  • 10
  • 19
7

Uninstalling Anaconda

To uninstall Anaconda, you can do a simple remove of the program. This will leave a few files behind, which for most users is just fine. See Option A.

If you also want to remove all traces of the configuration files and directories from Anaconda and its programs, you can download and use the Anaconda-Clean program first, then do a simple remove. See Option B.

Option A.

Use simple remove to uninstall Anaconda:

macOS–Open the Terminal.app or iTerm2 terminal application, and then remove your entire Anaconda directory, which has a name such as anaconda2 or anaconda3, by entering rm -rf ~/anaconda3.

Option B.

Full uninstall using Anaconda-Clean and simple remove.

NOTE: Anaconda-Clean must be run before simple remove.

Install the Anaconda-Clean package from Anaconda Prompt or a terminal window:

conda install anaconda-clean

In the same window, run one of these commands:

Remove all Anaconda-related files and directories with a confirmation prompt before deleting each one:

anaconda-clean

Or, remove all Anaconda-related files and directories without being prompted to delete each one:

anaconda-clean --yes

Anaconda-Clean creates a backup of all files and directories that might be removed, such as .bash_profile, in a folder named .anaconda_backup in your home directory. Also note that Anaconda-Clean leaves your data files in the AnacondaProjects directory untouched. After using Anaconda-Clean, follow the instructions above in Option A to uninstall Anaconda. Removing Anaconda path from .bash_profile

If you use Linux or macOS, you may also wish to check the .bash_profilefile in your home directory for a line such as:

export PATH="/Users/jsmith/anaconda3/bin:$PATH"

NOTE: Replace /Users/jsmith/anaconda3/ with your actual path.

This line adds the Anaconda path to the PATH environment variable. It may refer to either Anaconda or Miniconda. After uninstalling Anaconda, you may delete this line and save the file.

by official uninstalling way

Jerrybibo
  • 1,315
  • 1
  • 21
  • 27
VectorLu
  • 71
  • 1
  • 2
  • 1
    installing something to uninstall something else? What? Now, how do I uninstall anaconda-clean? :| – cs95 Jun 15 '19 at 02:26
7
rm -rf ~/anaconda3

nano ~/.bashrc
  • Ctrl+W to search for "Anaconda"
  • Delete or comment out the following lines:

    /home/sammuel/.bashrc
    # added by Anaconda3 4.2.0 installer
    export PATH="/home/sammuel/anaconda3/bin:$PATH"
    

When you’re done editing the file, type Ctrl+X to exit and y to save changes.

Anaconda is now removed from your server.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
bruce
  • 1,286
  • 11
  • 14
  • Also after deleting anaconda3 from the PATH, you need to run `source ~/bashrc` to make the changes effective on the current session. – Sachin Dangol Jul 06 '19 at 05:14
3

I simply:

rm -rf ~/anaconda3

...this removed conda also.

Then:

mousepad ~/.bashrc

...and removed the path line added at the very bottom (clearly identified by Anaconda as 'added by Anaconda'.

Worth noting that anaconda3 created a backup of my .bashrc file before modification, and named it as:

./bashrc-anaconda3.bak

...so I could always have just renamed this and deleted my modified .bashrc

Fiddy Bux
  • 703
  • 11
  • 22
3

In case you have multiple version of anaconda,

rm -rf ~/anaconda2 [for version 2]

rm -rf ~/anaconda3 [for version 3]

Open .bashrc file in a text editor

vim .bashrc

remove anaconda directory from your PATH.

export PATH="/home/{username}/anaconda2/bin:$PATH" [for version 2]

export PATH="/home/{username}/anaconda3/bin:$PATH" [for version 3]

Ashiq Imran
  • 2,077
  • 19
  • 17
2

To uninstall anaconda you have to:

1) Remove the entire anaconda install directory with:

rm -rf ~/anaconda2

2) And (OPTIONAL):

->Edit ~/.bash_profile to remove the anaconda directory from your PATH environment variable.

->Remove the following hidden file and folders that may have been created in the home directory:

rm -rf ~/.condarc ~/.conda ~/.continuum

source

HISI
  • 4,557
  • 4
  • 35
  • 51
2

I always try to follow the developers advice, since they are usually the ones that now how it would affect your system. Theoretically this should be the safest way:

Install the Anaconda-Clean package from Anaconda Prompt (terminal on Linux or macOS):

conda install anaconda-clean

In the same window, run one of these commands:

  1. Remove all Anaconda-related files and directories with a confirmation prompt before deleting each one:

anaconda-clean

  1. Remove all Anaconda-related files and directories without being prompted to delete each one:

anaconda-clean --yes

Anaconda-Clean creates a backup of all files and directories that might be removed in a folder named .anaconda_backup in your home directory. Also note that Anaconda-Clean leaves your data files in the AnacondaProjects directory untouched.

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

Javi
  • 913
  • 2
  • 13
  • 15
1

To uninstall Anaconda Fully from your System :

  1. Open Terminal
  2. rm -rf ~/miniconda
  3. rm -rf ~/.condarc ~/.conda ~/.continuum
vishwaraj
  • 487
  • 5
  • 5
1

In my case Anaconda3 was not installed in home directory. Instead, it was installed in root. Therefore, I had to do the following to get it uninstalled:

sudo rm -rf /anaconda3/bin/python
Jinhua Wang
  • 1,679
  • 1
  • 17
  • 44
1

Install the Anaconda-Clean package from Anaconda Prompt

conda install anaconda-clean

In the same window, run one of these commands: TO remove all Anaconda-related files and directories without being prompted to delete each one:

anaconda-clean --yes

Windows:

Use Windows Explorer to delete the envs and pkgs folders prior to running the uninstall in the root of your installation.

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.

1

In macOs rm -rf ~/opt/anaconda3

E_K
  • 2,159
  • 23
  • 39
0
rm -rf ~/anaconda3

It was enough

vimuth
  • 5,064
  • 33
  • 79
  • 116
Joe Llerena
  • 144
  • 1
  • 5
0

For windows

  • Install anaconda-clean module using

    conda install anaconda-clean
    

    then, run the following command to delete files step by step:

    anaconda-clean
    

    Or, just run following command to delete them all-

    anaconda-clean --yes
    
  • After this Open Control Panel> Programs> Uninstall Program, here uninstall that python for which publisher is Anaconda.

  • Now, you can remove anaconda/scripts and /anaconda/ from PATH variable.

Hope, it helps.

Yogesh Sanchihar
  • 1,080
  • 18
  • 25