如何使用Pip卸载部分安装的模块

3
我最近决定在我的电脑上安装tesseract,执行了pip3 install tesseract-ocr命令后,它开始下载cython,这让我意识到tesseract-ocr不是我想要的东西,所以我按下CTRL-C取消了该命令。然而,在我的目录中仍然有一个Cython文件夹,pip并没有在取消后清理它。另外,我无法使用pip uninstall cython,因为它告诉我还没有安装。我该如何彻底删除Cython?
3个回答

2

就我所知,您提供的软件包名称似乎未在全局pypi索引中出现,因此可能您漏掉了一些步骤?

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

在这种情况下,我认为答案变成了:
  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.


1
感谢您注意到包名称:已编辑为正确的包名称:tesseract-ocr。 - Pro Q
1
@ProQ 明白了 :) 我已经编辑了我的回答,确认 cython 是您正在安装的软件包的预期依赖项。您可以尝试在不完整的安装上完成原始安装,以便之后运行 pip3 uninstall tesseract-ocr - JHS

1

虽然您可以手动删除文件(通常位于文件夹site-packages中),但最好完全重新安装包,然后使用pip uninstall <package>来完全卸载它。


0

我在安装linux-remote的过程中,树莓派突然断电,也遇到了这个问题。

为了解决这个问题,我删除了位于以下位置的.whl文件:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接