.. _uninstall:

==================================
Uninstalling Anaconda Distribution
==================================

.. dropdown:: Need to uninstall Anaconda Navigator?
   :color: primary
   :animate: fade-in

   See :doc:`Uninstalling Navigator <../navigator/uninstall>`.

.. dropdown:: Need to uninstall Miniconda?
    :color: primary
    :animate: fade-in

    The uninstall instructions on this page are almost identical to those for Miniconda, but for specific uninstall instructions for Miniconda, see :doc:`Uninstalling Miniconda <../miniconda/uninstall>`.

.. note::
    
   The uninstall procedure might leave behind certain artifacts, such as desktop shortcuts or supplementary files, that must be deleted manually after completion. This is a known issue that is being addressed.

To uninstall your Anaconda installation:

.. tab-set::

    .. tab-item:: Windows

        #. (Optional) If you have created any environments outside your ``anaconda3`` directory, you can manually delete them to increase available disc space on your computer. This step must be performed before uninstalling Anaconda Distribution.

            .. dropdown:: Uninstall environments outside the ``anaconda3`` directory
                :color: primary
                :animate: fade-in

                #. Open Anaconda Prompt.

                #. View a list of all your environments by running the following command:

                    .. code-block:: none

                        conda info --envs
            
                    If you have any environments in a directory other than ``anaconda3``, you will need to uninstall the directory that contains the environments. Uninstalling the directory with the following command will both delete the environment files and deregister the environments.
            
                #. Open your preferred shell.

                #. Uninstall the directory by running the following command:

                    .. code-block:: none

                        # Replace <YOUR_USERNAME> with your Windows username
                        # Replace <PATH_TO_ENV_DIRECTORY> with the path to the directory that contains the environments
                        C:\Users\<YOUR_USERNAME>\anaconda3\_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>

        #. Search for "Control Panel" in the Windows search box and select the Control Panel app.
        #. Click **Uninstall a program** under **Programs**.
        #. Select Anaconda from the list of programs.
        #. Click **Uninstall**.
        #. Follow the on-screen instructions to complete the uninstallation process.

        .. dropdown:: Silent CLI uninstall
            :color: primary
            :animate: fade-in

            On Windows operating systems, you can silently uninstall Anaconda Distribution using either Command Prompt or PowerShell.

            .. tab-set::

                .. tab-item:: Command Prompt
            
                    Open a new Command Prompt window and run the following command:

                    .. code-block:: none

                        start /wait .\anaconda3\Uninstall-Anaconda3.exe /S

                .. tab-item:: PowerShell
            
                    Open a new PowerShell window and run the following command:

                    .. code-block:: none

                        Start-Process -FilePath ".\anaconda3\Uninstall-Anaconda3.exe" -ArgumentList "/S" -Wait

        .. note::

            An uninstall of Anaconda Distribution may take several minutes to complete.

    .. tab-item:: macOS or Linux

        #. Open your terminal application.
        #. (Optional) If you have created any environments outside your ``anaconda3`` directory, you can manually delete them to increase available disc space on your computer. This step must be performed before uninstalling Anaconda Distribution. 

            .. dropdown:: Uninstall environments outside the ``anaconda3`` directory
                :color: primary
                :animate: fade-in

                #. View a list of all your environments by running the following command:

                    .. code-block:: none

                        conda info --envs

                    If you have any environments in a directory other than ``anaconda3``, you will need to uninstall the directory that contains the environments. Uninstalling the directory with the following command will both delete the environment files and deregister the environments.

                #. Uninstall the directory by running the following command:

                    .. code-block:: none

                        # Replace <PATH_TO_ENV_DIRECTORY> with the path to the directory that contains the environments
                        ~/anaconda3/_conda constructor uninstall --prefix <PATH_TO_ENV_DIRECTORY>

        #. (Optional) Remove any conda initialization scripts from all your terminal shell profiles by running the following command:

            .. code-block:: none

                conda activate
                conda init --reverse --all

            .. dropdown:: What are conda initialization scripts?
                :color: primary
                :animate: fade-in

                Initialization scripts execute commands that configure your shell to automatically recognize conda commands.

                For a technical explanation of initialization, see `Conda initialization <https://docs.conda.io/projects/conda/en/stable/dev-guide/deep-dives/activation.html#conda-initialization>`_ in the official conda documentation.

                To see a list of shells where conda can be initialized, see `conda init <https://docs.conda.io/projects/conda/en/stable/commands/init.html>`_ in the official conda documentation.

        #. Remove your entire ``anaconda3`` directory with ``rm -rf``. Depending on your installation, this directory will be in your root folder or in your opt folder.

            .. warning::

                When paired with the ``-r`` (recursive) flag, the ``f`` (force) flag deletes all specified directories and the files within them without prompting you for confirmation. Double-check and verify that you have correctly specified the directories you intend to delete before running ``rm -rf``, as this action can't be undone.

            .. code-block:: none

                # The following are a few examples of how you might need to delete your anaconda3 folder
                rm -rf anaconda3
                rm -rf ~/anaconda3
                sudo rm -rf /opt/anaconda3                 
 
        #. (Optional) Remove the hidden ``.condarc`` file and ``.conda`` and ``.continuum`` directories from your home directory by running the following command:

            .. caution::

                Consider keeping a backup of the ``.condarc`` file, especially if you have custom configurations for conda and are planning on reinstalling.

            .. code-block:: none

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


        #. Close and reopen your terminal to refresh it. You should no longer see ``(base)`` in your terminal prompt.
