当conda使用很久之后,就会在conda安装路径下的pkgs路径下存在很多,而且会占用很多,我看自己机器上已经占用接近100g了,于是我就想对其进行清理,conda当然想到这个问题,有专门的命令conda clean
;
我们可以看一下命令行的提示conda clean -h
:
usage: conda clean [-h] [-a] [-i] [-p] [-t] [-f] [-c TEMPFILES [TEMPFILES ...]] [-d] [--json] [-q] [-v] [-y]
Remove unused packages and caches.
Options:
optional arguments:
-h, --help Show this help message and exit.
Removal Targets:
-a, --all Remove index cache, lock files, unused cache packages, and tarballs.
-i, --index-cache Remove index cache.
-p, --packages Remove unused packages from writable package caches. WARNING: This does not check for packages installed using symlinks
back to the package cache.
-t, --tarballs Remove cached package tarballs.
-f, --force-pkgs-dirs
Remove *all* writable package caches. This option is not included with the --all flag. WARNING: This will break
environments with packages installed using symlinks back to the package cache.
-c TEMPFILES [TEMPFILES ...], --tempfiles TEMPFILES [TEMPFILES ...]
Remove temporary files that could not be deleted earlier due to being in-use. Argument is path(s) to prefix(es) where files
should be found and removed.
Output, Prompt, and Flow Control Options:
-d, --dry-run Only display what would have been done.
--json Report all output as json. Suitable for using conda programmatically.
-q, --quiet Do not display progress bar.
-v, --verbose Can be used multiple times. Once for INFO, twice for DEBUG, three times for TRACE.
-y, --yes Do not ask for confirmation.
Examples:
conda clean --tarballs
命令行已经解释的十分清楚了,我们可以简单罗列几个重要的点进行汇总:
命令 | 说明 |
---|---|
conda clean -a | Remove index cache, lock files, unused cache packages, and tarballs |
conda clean -p | 移除未曾使用的安装包文件 |
conda clean -t | 移除缓存下来的压缩文件(不一定局限于tar/bz2/zip,这里很多conda也算压缩文件) |
接下来我们可以试一下conda clean -t
我们可以发现出现的文件都是.tar或者.conda之类的
具体需要删除哪些缓存文件看个人的要求,进行执行命令,我这里轻松清理了30多g缓存文件