How to remove pip package after deleting it manually

前端 未结 4 1909
孤街浪徒
孤街浪徒 2020-12-13 06:02

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<

相关标签:
4条回答
  • 2020-12-13 06:33
    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
    0 讨论(0)
  • 2020-12-13 06:33

    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. Copy the rm'ed directory to the original machine (ssh, ftp, whatever).
    3. pip uninstall the package (should work again then).

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

    0 讨论(0)
  • 2020-12-13 06:36

    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

    0 讨论(0)
  • 2020-12-13 06:41

    I met the same issue while experimenting with my own Python library and what I've found out is that pip freeze will show you the library as installed if your current directory contains lib.egg-info folder. And pip uninstall <lib> will give you the same error message.

    1. Make sure your current directory doesn't have any egg-info folders
    2. Check pip show <lib-name> to see the details about the location of the library, so you can remove files manually.
    0 讨论(0)
提交回复
热议问题