Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove pip package after deleting it manually

Tags:

python

pip

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.

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

EDIT

The package is 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.

TIA

like image 638
user3030969 Avatar asked Jan 23 '14 11:01

user3030969


2 Answers

packages installed using pip can be uninstalled completely using

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.

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

like image 80
Ashoka Lella Avatar answered Sep 23 '22 10:09

Ashoka Lella


  1. Go to the site-packages directory where pip is installing your packages.
  2. 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).
  3. Do the same with the package files for the package you want to delete (in this case, the psycopg2 directory).
  4. pip install YOUR-PACKAGE
like image 45
seddonym Avatar answered Sep 26 '22 10:09

seddonym