Last modified: Jun 20, 2025 By Alexander Williams

How to Uninstall Keras in Python

Keras is a popular deep learning library. Sometimes, you may need to uninstall it. This guide will help you remove Keras cleanly.

Why Uninstall Keras?

You might want to uninstall Keras for several reasons. Maybe you need a different version. Or you're cleaning up your Python environment.

Other times, conflicts with libraries like TensorFlow or PyTorch may require removal.

Check If Keras Is Installed

First, verify if Keras is installed. Run this command in your terminal:

 
pip show keras

If installed, you'll see package info. If not, you'll get a "not found" message.

Uninstall Keras Using Pip

The easiest way is using pip. Run this command:


pip uninstall keras

Confirm the removal when prompted. This will remove the main Keras package.

Remove Keras Dependencies

Keras may have dependencies. To remove them too, use:


pip uninstall keras tensorflow

This removes both Keras and TensorFlow, its common backend.

Uninstall Keras in Conda

For Anaconda users, use this command:


conda remove keras

Conda will handle dependencies automatically. Confirm the action when asked.

Verify Uninstallation

After uninstalling, check if Keras is gone:

 
import keras

You should get an ImportError. This confirms successful removal.

Clean Up Residual Files

Sometimes, files remain after uninstall. To clean them:


pip cache purge

This clears pip's cache. For conda, use conda clean --all.

Reinstall Keras If Needed

To reinstall Keras later, use:


pip install keras

Or for conda:


conda install keras

Troubleshooting

If you face issues, try these steps:

1. Use pip install --upgrade pip first

2. Check for multiple Python versions

3. Use virtual environments

For other library uninstalls, see our guide on uninstalling scikit-learn.

Conclusion

Uninstalling Keras is simple with pip or conda. Always verify removal and clean residual files. This keeps your Python environment tidy.

Remember to handle dependencies properly. This prevents conflicts with other ML libraries.