如何在手动删除pip包后删除它

[英]How to remove pip package after deleting it manually


I deleted a pip package with rm -rf command thinking that the package will be removed. Now the package has been deleted but it still shows up in pip list and I'm unable to remove it with pip uninstall nor can I update with pip install --upgrade.

我用rm -rf命令删除了一个pip包,认为该包将被删除。现在该包已被删除,但它仍然显示在pip列表中,我无法使用pip uninstall删除它,也无法使用pip install --upgrade更新。

I'd like to remove it completely. Can anyone please tell me how?

我想完全删除它。谁能告诉我怎么样?

EDIT

The package is psycopg2.

包是psycopg2。

If I try to uninstall :

如果我尝试卸载:

hammad@hammad-P5QL-E:~$ pip uninstall psycopg2
Can't uninstall 'psycopg2'. No files were found to uninstall.

This is the directory in which psycopg2 was located /usr/lib/python2.7/dist-packagesand I rm -rf 'd it from the same directory.

这是psycopg2所在的目录/usr/lib/python2.7/dist-packages,我rm -rf来自同一目录。

TIA

3 个解决方案

#1


38  

packages installed using pip can be uninstalled completely using

使用pip安装的软件包可以完全卸载

pip uninstall <package>

refrence link

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.

如果使用python setup.py install安装软件包,pip uninstall可能会失败,因为它们不会留下元数据来确定安装了哪些文件。

packages still show up in pip list if their paths(.pth file) still exist in your site-packages or dist-packages folder. You'll need to remove them as well in case you're removing using rm -rf

如果他们的路径(.pth文件)仍存在于您的site-packages或dist-packages文件夹中,则软件包仍会显示在pip列表中。如果您使用rm -rf删除,则还需要删除它们

#2


6  

  1. Go to the site-packages directory where pip is installing your packages.
  2. 转到pip正在安装软件包的site-packages目录。

  3. You should see the egg file that corresponds to the package you want to uninstall. Delete the egg file (or, to be on the safe side, move it to a different directory).
  4. 您应该看到与要卸载的包对应的egg文件。删除egg文件(或者,为了安全起见,将其移动到另一个目录)。

  5. Do the same with the package files for the package you want to delete (in this case, the psycopg2 directory).
  6. 对要删除的包的包文件(在本例中为psycopg2目录)执行相同操作。

  7. pip install YOUR-PACKAGE
  8. 请安装YOUR-PACKAGE

#3


1  

I'm sure there's a better way to achieve this and I would like to read about it, but a workaround I can think of is this:

我确信有更好的方法来实现这一点,我想了解它,但我能想到的解决方法是:

  1. Install the package on a different machine.
  2. 在不同的计算机上安装软件包。

  3. Copy the rm'ed directory to the original machine (ssh, ftp, whatever).
  4. 将rm'ed目录复制到原始机器(ssh,ftp,无论如何)。

  5. pip uninstall the package (should work again then).
  6. pip卸载包(应该再次工作)。

But, yes, I'd also love to hear about a decent solution for this situation.

但是,是的,我也很想听到这种情况的合适解决方案。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2014/01/23/720190997464b313c6a4bd202a9b514f.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告