如何在手動刪除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.

但是,是的,我也很想聽到這種情況的合適解決方案。


注意!

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



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