简体   繁体   中英

How does pip know what to uninstall?

Say you installed a package foo .
Now you're uninstalling foo with pip.

What exactly does pip uninstall foo do?
How does it know to do that?

Does it just delete the foo folder and its eggs from the Python packages directory? (+ any relevant dependencies)

Or does pip uninstall sometimes do more than that?
Maybe package authors provide a uninstall.py file maybe.


I understand that if I want to make sure I uninstall a Python package, I can run:

python setup.py install --record files.txt

while installing the package, then remove all the files in files.txt .

Is that essentially what pip does: track what files were created during setup and remove them? What more to it is there than that?

Is that essentially what pip does: track what files were created during setup and remove them?

Yes.

What more to it is there than that?

If all recorded files were successfully removed pip uninstall removes the package directory and the corresponding .dist-info directory (where it stored metadata including the list of files in the package).

And that's all. The end of the story.

Is that essentially what pip does: track what files were created during setup and remove them?

There's one detail here: pip uninstall x will uninstall the x package, but if it had to install other dependencies before, those will stay, since it doesn't check if the dependencies used by x are still used by other packages. They always stay, and that can be a little annoying sometimes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM