In this tutorial, we explain how to completely uninstall Anaconda in Ubuntu Linux. That is, we explain how to perform a clean uninstallation of Anaconda in Linux Ubuntu. The YouTube tutorial accompanying this webpage is given below.
The Reasons For Uninstalling Anaconda in Linux Ubuntu
If you are a student learning Python or an engineer, you would probably need to uninstall Anaconda at least once and install it again. Namely, it can happen that the packages in the base installation of Anaconda become corrupted or unusable due to frequent use of pip install, and some compatibility issues might appear (keep in mind that it is a suggested practice to always install packages in insolated Anaconda environments and not in the base environment). If we do not perform a clean uninstall of Anaconda, next time we install Anaconda, we will automatically load the previous settings. Uninstalling Anaconda in Linux Ubuntu is not as simple as erasing the Anaconda installation folder. We have to erase the installation folder, several hidden folders, and we have to remove some lines from the .bashrc file that is automatically executed every time we open a terminal. If we do not follow these steps, we will not be able to perform a clean uninstall of Anaconda, and the next time we load Anaconda, we might load the settings from the previous installation. Consequently, it is very important to learn how to properly uninstall Anaconda in Linux Ubuntu.
Step 0: Find Anaconda installation folder
First of all, let us find where Anaconda is installed (the folder used for installation). Open a terminal and type
which conda
In our case, it is
/home/aleksandar/anaconda3/condabin/conda
This means that anaconda is installed in the folder
/home/aleksandar/anaconda3/
This is very important information that will be used in STEP 2 (see below).
Step 1: Remove any Conda/Anaconda initialization scripts from the terminal shell profiles.
Anaconda places initialization lines in the file .bashrc in the home folder. To see this, open a terminal, and type
sudo apt update && sudo apt upgrade
sudo apt-get install gedit
cd ~
gedit .bashrc
and you should see at the end of the file
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/aleksandar/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/aleksandar/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/aleksandar/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/aleksandar/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
To erase this line and similar lines, close the file, go back to the terminal, and type
conda activate
conda init --reverse --all
Then, double check that these lines are erased, by typing\
gedit .bashrc
and the above-mentioned Anaconda bash lines should be automatically erased. If not, you can erase them manually in the file.
Step 2: Erase the Anaconda installation folder, as well as other folders and files, including hidden folders
In step 0, we learned that the installation folder of Anaconda is here
/home/aleksandar/anaconda3/
This folder has to be erased. Let us erase this folder. Open a terminal and type
rm -rf ~/anaconda3
Then, type
ls -la
To list all the folders. You will find several hidden folders related to anaconda that start with “.” (dot or period). They are: “.conda” and “.anaconda“. These folders are in the home folder, and they need to be erased. To erase these hidden folders, in the terminal type:
rm -rf ~/.conda
rm -rf ~/.anaconda
Then, open Files program from the Linux Ubuntu Graphics User Interface (on the right side), and press CTRL+F to search, and search conda. You will find a folder “conda” in the folder .cache. Go to the folder .cache and erase the folder conda. Then, you will find “anaconda-client” in the folder .continuum, and erase “anaconda-client”. Erase these subfolders.