How to Uninstall TensorFlow in Conda

Anika Tabassum Era Feb 02, 2024
  1. Uninstall TensorFlow from the Environment Variable Manually
  2. Uninstall TensorFlow from Environment Variable via Command Prompt
  3. Uninstall TensorFlow via pip
How to Uninstall TensorFlow in Conda

TensorFlow being in the flow of constant upgradation often requires uninstalling the previous version and adding the new one. It is a good practice to uninstall any package after use, as in the next drive, you might need to use the newer version.

To uninstall TensorFlow, we will follow two methods incorporating the environment variable. And another method that directly links with the pip.

The following output and procedure will guide you through the whole process of uninstalling TensorFlow from the Anaconda.

Uninstall TensorFlow from the Environment Variable Manually

In this regard, we will have an environment set to install the TensorFlow packages. You will notice a dropdown from the center view in the upper right section.

We will select the Installed option, and we can also do a filter search for TensorFlow. Next, the task is to mark TensorFlow from the installed packages option and press the Apply button for further procedure.

After uninstalling TensorFlow, the package import might seem to run. But in reality, the package is successfully removed.

You can always go for a check of the package lists with the following code snippet.

Code Snippet:

# import tensorflow
import tensorflow as tf
#check packages
!conda list
#or
!pip list

We tried to demonstrate the whole procedure in the following output.

Output:

Uninstall TensorFlow from the Environment Variable Manually

Uninstall TensorFlow from Environment Variable via Command Prompt

We will select the targeted environment variable and run the CMD.exe prompt application in this case. A terminal-like interface will pop up and there.

You will be required to type the following:

conda uninstall tensorflow

This specific line will initiate all the processes to uninstall the packages of TensorFlow. The following output has a preview of how this method works.

Output:

Uninstall TensorFlow from Environment Variable via Command Prompt

Uninstall TensorFlow via pip

Usually, when we deal with pip, we consider the base application and collectively install packages with all sorts of metadata. While in the case of handling environment variables and package installations, the load is comparatively lower.

However, we will directly open up a Jupyter Notebook, and in the code cell, type as follows -

!pip list

After running the cell, we will notice there is TensorFlow available, and then in the next drive, we run the code below:

!pip uninstall -y tensorflow

As a result, the TensorFlow package will be fully uninstalled, and when importing the module, you will experience a ModuleNotFoundError.

Output:

Uninstall TensorFlow via pip

These are the basic ways to uninstall TensorFlow packages from Anaconda.

Anika Tabassum Era avatar Anika Tabassum Era avatar

Era is an observer who loves cracking the ambiguos barriers. An AI enthusiast to help others with the drive and develop a stronger community.

LinkedIn Facebook