Uninstall TensorFlow: The Unofficial Troubleshooting Guide

There are lots of ways to install TensorFlow, which means (unfortunately) there is no one-size-fits-all solution for uninstalling it. The internet is littered with questions from frustrated developers and data scientists trying to remove this behemoth from their machines.

This post enumerates the solutions I’ve seen.

Uninstall TensorFlow

If you installed TensorFlow with pip

  • In most cases, you should be able to run: pip install tensorflow
  • Or, if you installed tensorflow-gpu: pip install tensorflow-gpu
  • Once in a while, the pip in your current path is not the same pip you used to install it. In this case, find the Python environment where the TensorFlow install lives and run: /path/to/python -m pip uninstall tensorflow

If you installed TensorFlow with conda

  • If you want to reuse your conda environment, you can run: conda remove tensorflow
  • If you’re willing to start a new conda environment, just remove the current one: conda remove --name <your environment> --all

If you built TensorFlow from source

  • Go to the source directory and run: python setup.py develop --uninstall

If you’re on Windows and you’re still having trouble

Finally, if one of the solutions above worked, you may also want to remove the packages TensorFlow installs automatically.

Alternatives

On the other hand, you may not actually need to uninstall TensorFlow. Here are a few alternatives to consider.

If you want to use TensorFlow in your current environment

  • You can upgrade the package: pip install tensorflow --upgrade

You can setup a virtual environment

  • You probably want to use Anaconda: conda create --name tensorflow-env python=3.8 pip tensorflow
  • But you can also use virtualenv. This requires a few commands:
    1. python -m venv tensorflow-venv
    2. source tensorflow-env/bin/activate
    3. pip install tensorflow

You can use Docker

The TensorFlow docs have a good page on using Docker for TensorFlow. Ultimately, this is what I would recommend if you can make it work. Getting TensorFlow off your actual machine and into Docker will save you headaches down the road.

What am I missing?

I hope this helps. Did I miss something obvious? Let me know in the comments section.

Hello, my name is Ben Cook

I help data scientists deploy their code. If there's any way I can serve you, don't hestitate to reach out. You can also find out a little more about me or download my free guide: 8 Best Practices for Building Machine Learning Pipelines.

Thanks for stopping by!

Contact

Get in touch

Connect

Free Guide

Download my free guide: 8 Best Practices for Building Machine Learning Pipelines