I was helping a data science team in San Francisco that faced version conflicts between TensorFlow and Keras. The issue was simple: multiple versions of Keras were installed across different Python environments, causing import errors.
I’ve personally encountered this problem many times while working with Python Keras for deep learning projects. The good news is that uninstalling Keras is simple, once you know the right commands for your platform.
In this tutorial, I’ll show you how to uninstall Keras completely from your system, whether you’re using Windows, macOS, Linux, Anaconda, or a virtual environment.
What is Keras in Python?
Before uninstalling, let’s quickly understand what Keras is.
Keras is a high-level deep learning API written in Python that runs on top of TensorFlow. It allows you to build and train neural networks easily.
However, sometimes you might need to uninstall Keras if:
- You’re upgrading to a newer version of TensorFlow (which already includes Keras).
- You’re facing version conflicts between TensorFlow and standalone Keras.
- You want to clean up your Python environment.
Method 1 – Uninstall Keras Using pip (Recommended)
If you installed Keras using pip, you can uninstall it directly from the terminal or command prompt.
This is the most common and reliable way to remove Keras in Python.
Steps to uninstall Keras using pip:
- Open your Command Prompt (Windows) or Terminal (macOS/Linux).
- Type the following command and press Enter.
pip uninstall kerasYou can see the output in the screenshot below.

After running this command, pip will ask for confirmation. Type y and press Enter to proceed.
If you also want to remove any dependencies related to Keras, you can use the following command:
pip uninstall keras tensorflow tensorflow-gpuTip:
Sometimes, multiple versions of Python are installed on your system. To make sure you’re uninstalling Keras from the correct version, use:
python -m pip uninstall kerasThis ensures the uninstall command is executed for the specific Python version you’re using.
Method 2 – Uninstall Keras on Windows (Python Installed via pip)
When working on Windows systems, uninstalling Keras is straightforward using the Command Prompt.
Here’s how I usually do it when working on my Windows 11 machine.
Steps:
- Press Windows + R, type cmd, and hit Enter.
- Check if Keras is installed using:
pip show kerasIf Keras is listed, proceed to uninstall it:
pip uninstall keras- To verify the uninstallation, run:
pip listIf Keras no longer appears in the list, it’s successfully removed.
If you’re using Python 3, replace pip with pip3:
pip3 uninstall kerasMethod 3 – Uninstall Keras on macOS
On macOS, you can use the Terminal to uninstall Keras.
I often use this method on my MacBook Pro when switching between TensorFlow and PyTorch environments.
Steps to uninstall Keras on macOS:
- Open the Terminal app.
- Type the following command:
pip3 uninstall keras- Confirm the uninstallation when prompted.
To double-check that Keras is gone, run:
pip3 show kerasIf no output appears, Keras has been successfully uninstalled.
Method 4 – Uninstall Keras on Linux
If you’re running Python on Ubuntu or any other Linux distribution, the process is similar. I often use this when managing cloud servers or Docker containers for deep learning experiments.
Steps to uninstall Keras on Linux:
- Open your terminal.
- Run the following command:
sudo pip3 uninstall keras- Enter your system password when prompted.
To verify the uninstallation:
pip3 list | grep kerasIf no output appears, Keras has been successfully removed.
Method 5 – Uninstall Keras in Anaconda (conda environment)
If you’re using Anaconda, Keras might have been installed using conda or pip inside a conda environment.
Here’s how to uninstall it properly.
Steps to uninstall Keras using conda:
- Open the Anaconda Prompt.
- Activate your environment (for example,
tensorflow_env):
conda activate tensorflow_env- Uninstall Keras:
conda remove keras- Confirm by typing
ywhen prompted.
If you installed Keras using pip inside the conda environment, use:
pip uninstall kerasTo confirm, check the installed packages:
conda list | find "keras"If no Keras package appears, it’s been successfully removed.
Method 6 – Uninstall Keras in a Virtual Environment
When working on Python projects, I always recommend using virtual environments. They isolate dependencies and prevent conflicts between packages like TensorFlow and Keras.
If you installed Keras inside a virtual environment, here’s how to remove it.
Steps:
- Activate your virtual environment:
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate- Once activated, uninstall Keras:
pip uninstall keras- To confirm removal:
pip listIf Keras no longer appears, it’s successfully uninstalled.
When you’re done, deactivate the virtual environment:
deactivateMethod 7 – Remove Keras Manually (if uninstall fails)
Sometimes, pip or conda might not remove all Keras files, especially if installations were done globally or manually.
In such cases, you can delete the Keras folder manually from your Python site-packages directory.
Steps to remove Keras manually:
- Locate your Python installation directory.
For example:
- Windows: C:\Users\<YourName>\AppData\Local\Programs\Python\Python310\Lib\site-packages\
- macOS/Linux: /usr/local/lib/python3.10/site-packages/
- Find and delete the following folders (if they exist):
- keras
- keras_preprocessing
- keras_applications
- Restart your terminal or IDE (like PyCharm, VS Code, or Jupyter Notebook).
Once deleted, Keras will be completely removed from your system.
Method 8 – Verify Keras Uninstallation in Python
After uninstalling, you can verify that Keras is no longer available in your Python environment.
Here’s a quick test you can run:
import kerasIf Keras is successfully uninstalled, you’ll see an error like this:
ModuleNotFoundError: No module named 'keras'This confirms that Keras has been completely removed.
Bonus Tip – Reinstall Keras (if needed)
If you ever want to reinstall Keras, you can do it easily using pip:
pip install kerasOr, if you’re using TensorFlow 2.x (which already includes Keras), you can directly import it like this:
from tensorflow import kerasThis is the preferred modern way to use Keras in Python.
So that’s how you can uninstall Keras in Python, across Windows, macOS, Linux, Anaconda, and virtual environments.
While uninstalling Keras might seem like a small task, doing it properly ensures your Python environment stays clean and conflict-free. I always recommend using virtual environments or Anaconda for managing deep learning libraries, as it makes switching between frameworks like TensorFlow and PyTorch much smoother.
You may also read:
- How to Install and Set Up Keras in Python
- Build Your First Neural Network in Python Using Keras
- How to Update Keras in Python

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.