Pip: How to clear pip cache safely?

Created on 2 Nov 2017  路  8Comments  路  Source: pypa/pip

I want to known that how to clear pip cache safely?

1, Does pip have a cmd like "apt-get clean" to remove all the cached packages to make my system image smaller?
2, Can i remove /boot/.cache/pip and ~/.cache/pip manually?(use "sudo rm -rf /boot/.cache/pip" and "sudo rm -rf ~/.cache/pip")?
3, Does pip and pip3 use the same cache dir( /boot/.cache/pip and ~/.cache/pip)?

thank you.

cache auto-locked support

Most helpful comment

I'll also add that there's an idea to create a pip cache command to make cache management easier --- #4685.

All 8 comments

  1. no
  2. i beleive thats the correct list of paths for the case you outline (i presume /boot/ is the home)
  3. that depends on the pip versions for each pip - if you use the distro-packaged one for both commands then they use the exactly same cache, if there is a pip version difference (like dueto virtualenv, then that may change some details if the distro version is a really old one (like pip 1.5.x)

I'll also add that there's an idea to create a pip cache command to make cache management easier --- #4685.

blindly deleting files or whole directories from the HTTP cache based on timestamp is safe

From #5110.

I think it is always safe to delete the cache, because it is a cache. Here's how I do it on Windows, which I'm constrained to use at work:

cd %USERPROFILE%\AppData\Local\pip
del /f /s /q cache > NUL

I do have to do this from time to time, because I will get PermissionError from Windows sometimes on accessing the cache, if too much stuff is in

Generally the obstacle to implementation is that anyone who wants to pick this up (and isn't already a Pip dev) needs to learn the internals and follow the idioms of the project. That's a nontrivial task.

Indeed @gwerbin! I made https://github.com/pypa/pip/issues/4685#issuecomment-464824545, in case someone wants to work on this and feel that's the blocker.


I am going to go ahead and close this in favor of #4685, as the long term resolution. @RonnyPfannschmidt's https://github.com/pypa/pip/issues/4830#issuecomment-341380689 answers all questions from OP.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Since this shows up in pip cache remove web search, you can find more details about this here: https://stackoverflow.com/a/61762308/1931274

Was this page helpful?
0 / 5 - 0 ratings