21

I'm using Tensorflow-0.8 on Ubuntu14.04. I first install Tensorflow from sources and then setup Tensorflow for development according to the official tutorial. When I want to uninstall tensorflow using the following command

sudo pip uninstall tensorflow

I encountered the following error:

Can't uninstall 'tensorflow'. No files were found to uninstall

Could anyone tell me where is wrong?

For your reference, the output of pip show tensorflow is

Name: tensorflow
Version: 0.8.0
Location: /home/AIJ/tensorflow/_python_build
Requires: numpy, six, protobuf, wheel

But I actually find another Tensorflow directory at

/usr/local/lib/python2.7/dist-packages/tensorflow

Besides, I also have a question about the general usage of Python. I have seen two quite similar directories in my system, i.e.

/usr/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages

Could any one tell me the differences between them? I noticed that everytime I use sudo pip install <package>, the package will be installed to /usr/local/lib/python2.7/dist-packages, could I instead install packages into /usr/lib/python2.7/dist-packages using pip install?

Thanks a lot for your help in advance!

ROBOT AI
  • 1,217
  • 3
  • 16
  • 27

2 Answers2

10

It could be because you didn't install Tensorflow using pip, but using python setup.py develop instead as your link shows.

pip uninstall is likely to fail if the package is installed using python setup.py install as they do not leave behind metadata to determine what files were installed.

Therefore, you should be able to unistall Tensorflow with the option -u or --unistall of develop

cd /home/AIJ/tensorflow/_python_build
python setup.py develop --uninstall

To answer for the second (interestring) question about the two dist-package created under /usr/lib/python2.7 and /usr/local/lib/python2.7 it exists already a great Stack Overflow answer on the topic.

PS: Tensorflow is a good library, you should consider not uninstall it :)

Community
  • 1
  • 1
Kruupös
  • 5,097
  • 3
  • 27
  • 43
  • Haven't tried but looks like this should be the correct answer. @OP - can you check and comment/upvote if this works – Rishi Dua Sep 28 '16 at 07:08
  • @Max That's exactly where the problem lays. I successfully uninstalled Tensorflow in your way (and then reinstall it in virtualenv:) ). Thanks a lot for offering the solution and giving a good reference for my second question! – ROBOT AI Sep 28 '16 at 19:06
  • @ROBOT AI, My pleasure! I learn a lot of things myself while writing the answer. You said you want to install Tensorflow in`virtualenv`and there is nothing wrong with that. imo, I prefer [`Docker`](https://hub.docker.com/r/tensorflow/tensorflow/). It could be more relevant for you as well. – Kruupös Sep 28 '16 at 20:02
  • 1
    None of these answers helped me in my Anaconda virtualenv. So what I did was `rm -rf tensor*` from the `site-packages` directory. – Gokul NC Feb 08 '18 at 05:32
  • @GokulNC I don't think `rm -rf` is a good strategy: because you may still leave metadata somewhere else in you environment thus creating conflicts later on. I just read in [package remove](http://stuarteberg.github.io/conda-docs/using/pkgs.html#package-remove) from Anaconda's doc that `conda uninstall tensorflow` should just work. If you confirm this (e.g. with another package) I will update my answer accordingly. – Kruupös Feb 08 '18 at 09:11
  • `conda uninstall tensorflow` didn't help, it says `PackageNotFoundError: Package(s) is missing from the environment: tensorflow` It's because I installed TF from the [official wheel using pip](https://www.tensorflow.org/install/install_linux#the_url_of_the_tensorflow_python_package), but pip doesn't seem to find it when I do `pip uninstall tensorflow`. – Gokul NC Feb 08 '18 at 09:34
7

I believe pip isn't installed for python2.7

try :

pip -V

On my system for instance it says :

pip 8.1.2 from /usr/lib/python3.4/site-packages (python 3.4)

So basically using pip uninstall will only remove packages for python3.4 (and not python2.7).

So I don't use pip binary as such, and rather, call pip module from inside python.

In your case :

python2.7 -m pip uninstall tensorflow
Loïc
  • 11,804
  • 1
  • 31
  • 49
  • Thanks for your kind reply! The results of `pip -V` is `pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)`. Then I guess pip may have been installed for python2.7, isn't it? Then I also try `python2.7 -m pip uninstall tensorflow`, but the same error remains. – ROBOT AI Sep 27 '16 at 16:52