Anaconda is a widely used open-source platform for Python and R programming, primarily geared toward data science, machine learning, and scientific computing. It comes with numerous pre-installed packages and tools, making it ideal for quickly setting up a data science environment. However, there may come a time when you need to uninstall Anaconda—either to reclaim storage space or switch to a different Python setup.
In this guide, we’ll walk you through the complete steps to fully uninstall Anaconda from your Ubuntu 22.04 system.
Prerequisites
Before you begin, make sure you have:
- A system running Ubuntu 22.04
- A user account with sudo privileges
Step 1: Delete the Anaconda Installation Folder
Start by launching a terminal. The Anaconda directory is usually located in your home directory under either anaconda3 or miniconda3. You can remove it using the following command:
rm -rf ~/anaconda3
Or, if you have Miniconda installed:
rm -rf ~/miniconda3
Step 2: Remove Anaconda from the PATH Environment Variable
Next, clean up your environment by removing Anaconda from your system’s PATH variable. Open the .bashrc file in your home directory using a text editor:
nano ~/.bashrc
Look for a block of text between the following markers:
# >>> conda initialize >>>
# ... some lines ...
# <<< conda initialize <<<
Delete everything between (and including) these lines.
Save and close the file. Then, apply the changes by running:
source ~/.bashrc
Step 3: Remove Hidden Anaconda Files and Folders
To ensure a complete cleanup, remove any hidden files and directories that Anaconda might have created:
rm -rf ~/.conda
rm -rf ~/.condarc
rm -rf ~/.continuum
Conclusion
Following these steps will completely uninstall Anaconda from your Ubuntu 22.04 system. This helps free up disk space and allows you to install a new Python environment or other tools as needed.