Pro Q
Pro Q

Reputation: 5048

How to uninstall partially installed module with Pip

I recently decided to try to install tesseract onto my computer and ran pip3 install tesseract-ocr.

It then started to download cython which alerted me to the fact that tesseract-ocr was not what I wanted, so I hit CTRL-C to cancel the command.

However, it appears that there is still a Cython folder inside my directories; pip did not clean up after the cancel. Also, I can't use pip uninstall cython because it just tells me it hasn't been installed yet.

What can I do to get a clean removal of Cython?

Upvotes: 3

Views: 7615

Answers (3)

Gary Wassell
Gary Wassell

Reputation: 1

I also had this problem when I lost power to my Pi part way through installing linux-remote.

I deleted the .whl file to resolve the problem, which was located here in my case:

/root/.cache/pip/wheels/a0/75/....../linux-remote-3.4-cp37-none-any.whl

Upvotes: 0

Pro Q
Pro Q

Reputation: 5048

While you can delete the files manually (usually residing in the folder site-packages, it is better to completely reinstall the package, and then use pip uninstall <package> in order to completely uninstall it.

Upvotes: 1

JHS
JHS

Reputation: 1428

FWIW, the package name you gave doesn't appear to be on the global pypi index, so perhaps you left some steps out?

pip3 install opencv-tesseract
Collecting opencv-tesseract
  Could not find a version that satisfies the requirement opencv-tesseract 
  (from versions: )
No matching distribution found for opencv-tesseract

In this type of situation, I think the answer becomes:

  1. In the future, let it finish installing, then uninstall it once complete, so that it can clean itself up properly.

  2. Don't panic if pip is installing dependencies of the thing you're installing. When I pip3 install tesseract-ocr as in the edited question, I see:

    Collecting tesseract-ocr
      Downloading tesseract-ocr-0.0.1.tar.gz
    Collecting cython (from tesseract-ocr)
    ...
    

    Which is totally normal and just indicates you are installing a dependency of your dependency, in this case cython, so no need to cancel it.

  3. Install dependencies to disposable virtualenvs so that you don't pollute your global packages and file system: https://virtualenv.pypa.io/en/stable/

  4. You will probably just have to delete the leftover cython directories.

Upvotes: 2

Related Questions