How to uninstall TensorFlow from your computer
The Python tensorflow package is known to be difficult to uninstall because there are many ways to install it on your machine.
The first command you should try is to use pip to uninstall the package:
If you didn’t use sudo to install the package, then you don’t need it to uninstall:
If that doesn’t work, then try to use the python -m command to run library module as a script:
If you have the older tensorflow-gpu package, uninstall it using one of the commands below:
If you installed TensorFlow using conda, then you can use the conda remove command as follows:
If you installed TensorFlow on Apple Silicon Macs, then use this command to uninstall it:
Apple Silicon Macs have a special TensorFlow version that uses the Metal API to gain access to the GPU.
If you’re using a Windows computer, then you might get a FileNotFoundError when running the pip uninstall tensorflow command.
This error happens because Windows can’t delete a file that has a path longer than 260 characters. Follow this guide to remove that limit.
If you still see the error, then you can try to delete the package manually from the site-packages folder.
To get the location of your package, run the pip show command as follows:
As you can see, pip shows the location where the package is installed. Go into the folder and delete the tensorflow folder. You might need to add the sudo privilege on Linux and Mac.
Finally, if you use a virtual environment to install the tensorflow package, make sure that the environment is activated before you uninstall it.
You can see if a virtual environment is activated or not by looking at your command prompt.
When a virtual environment is activated, the name of that environment will be shown inside parentheses as shown below:
In the picture above, the name of the virtual environment (base) appears when the Conda virtual environment is activated.
Once activated, you can uninstall the package using either pip or conda commands.
I hope this tutorial helps you to remove TensorFlow from your computer. See you in other tutorials!
Get 100 Python Snippets Book for FREE
100 Python snippets that you can use in various scenarios
Save 1000+ hours of research and 10x your productivity

report this ad
About
Sebhastian is a site that makes learning programming easy with its step-by-step, beginner-friendly tutorials.
Learn JavaScript and other programming languages with clear examples.
Free Code Snippets Book
Get my FREE code snippets Book to 10x your productivity here

report this ad
Как полностью удалить TensorFlow?
Я случайно установил TensorFlow для 64-битной Ubuntu / Linux, с включенным графическим процессором. Когда я устанавливал только с 64-битным процессором Linux, я получал ошибку сегментации при импорте тензорного потока из консоли python.
2 ответа
При запуске в conda env или любом другом виртуальном окружении sudo не работает. Таким образом, вы можете использовать:
python3 -m — самый безопасный способ убедиться, что вы используете pip3 , а не pip2 .
Зависит от того, как Вы устанавливаете его, рассматривая то, что существует несколько способов сделать это здесь . Большей частью универсального пути люди делают это через зернышко, проверьте использование:
Cannot uninstall Tensorflow
The following image shows various versions of tensorflow installed however I am not able to uninstall it.
I tried pip, pip3, conda and still it does not recognise tensorflow.
How to remove Tensorflow completely ?
7 Answers 7
Did you try uninstalling by removing protobuf first and then tensorflow
And most probably you didn’t installed tensorflow via conda that’s why you were getting that error(package not found) To figure out which package was used to install the particular package you can list using the following command
And use appropriate command to uninstall the package
Try "pip uninstall tensorflow-___" at the place of dashes add CPU or gpu according to the build that you have installed.
You can delete any python package that was installed globally, manually by going into your global site-packages folder and deleting the files manually.
pip show tensorflow should give you, dependant on your version of pip the location of tensorflow on your machine.
Usually its /usr/lib/pythonX.X/site-packages where X.X can be substituted with your version of python/pip. The same should work for Windows machines.
You can then uninstall tensorflow bydeleting the folder tensforflow. You most likely will require sudo priveliges.
After you are done, there should be no traces of tensorflow on your machine.
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 uninstall tensorflow
- Or, if you installed tensorflow-gpu: pip uninstall 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
- Check out this thread on GitHub
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:
- python -m venv tensorflow-venv
- source tensorflow-env/bin/activate
- 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.