<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Conda on Edward&#39;s Blog</title>
    <link>https://example.org/tags/conda/</link>
    <description>Recent content from Edward&#39;s Blog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    
    <managingEditor>xxx@example.com (D-Sketon)</managingEditor>
    <webMaster>xxx@example.com (D-Sketon)</webMaster>
    
    <copyright>本博客所有文章除特别声明外，均采用 BY-NC-SA 许可协议。转载请注明出处！</copyright>
    
    <lastBuildDate>Tue, 01 Sep 2026 11:10:38 +0800</lastBuildDate>
    
    
    <atom:link href="https://example.org/tags/conda/index.xml" rel="self" type="application/rss&#43;xml" />
    

    
    

    <item>
      <title>清理Anaconda和pip缓存指南</title>
      <link>https://example.org/post/%E6%B8%85%E7%90%86anaconda%E5%92%8Cpip%E7%BC%93%E5%AD%98%E6%8C%87%E5%8D%97/</link>
      <pubDate>Tue, 01 Sep 2026 11:10:38 &#43;0800</pubDate>
      <author>xxx@example.com (D-Sketon)</author>
      <guid>https://example.org/post/%E6%B8%85%E7%90%86anaconda%E5%92%8Cpip%E7%BC%93%E5%AD%98%E6%8C%87%E5%8D%97/</guid>
      <description>
        <![CDATA[<h1>清理Anaconda和pip缓存指南</h1><p>作者：D-Sketon（xxx@example.com）</p>
        
          <p>在使用 Anaconda 和 pip 管理 Python 包的过程中，缓存文件会逐渐累积，占用大量磁盘空间，甚至可能导致依赖冲突或安装错误。定期清理缓存有助于释放空间并解决一些奇怪的问题。以下提供针对 <code>conda</code> 和 <code>pip</code> 的缓存清理方法。</p>
<hr>
<h2 id="1-清除-pip-缓存">
<a class="header-anchor" href="#1-%e6%b8%85%e9%99%a4-pip-%e7%bc%93%e5%ad%98"></a>
1. 清除 pip 缓存
</h2><h3 id="方法一使用-pip-自带的清理命令推荐">
<a class="header-anchor" href="#%e6%96%b9%e6%b3%95%e4%b8%80%e4%bd%bf%e7%94%a8-pip-%e8%87%aa%e5%b8%a6%e7%9a%84%e6%b8%85%e7%90%86%e5%91%bd%e4%bb%a4%e6%8e%a8%e8%8d%90"></a>
方法一：使用 pip 自带的清理命令（推荐）
</h3><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>pip cache purge
</span></span></code></pre></div><p>该命令会删除所有缓存的 wheel 文件、下载的包索引信息等。如果只想查看缓存大小而不删除，可先运行：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>pip cache info
</span></span></code></pre></div><h3 id="方法二手动删除缓存目录">
<a class="header-anchor" href="#%e6%96%b9%e6%b3%95%e4%ba%8c%e6%89%8b%e5%8a%a8%e5%88%a0%e9%99%a4%e7%bc%93%e5%ad%98%e7%9b%ae%e5%bd%95"></a>
方法二：手动删除缓存目录
</h3><ul>
<li><strong>Linux / macOS</strong>：<code>~/.cache/pip</code></li>
<li><strong>Windows</strong>：<code>%LocalAppData%\pip\cache</code></li>
</ul>
<p>直接删除整个目录：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Linux / macOS</span>
</span></span><span style="display:flex;"><span>rm -rf ~/.cache/pip
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Windows (PowerShell)</span>
</span></span><span style="display:flex;"><span>Remove-Item -Recurse -Force $env:LOCALAPPDATA<span style="color:#ae81ff">\p</span>ip<span style="color:#ae81ff">\c</span>ache
</span></span></code></pre></div><hr>
<h2 id="2-清除-conda-缓存">
<a class="header-anchor" href="#2-%e6%b8%85%e9%99%a4-conda-%e7%bc%93%e5%ad%98"></a>
2. 清除 conda 缓存
</h2><p><code>conda</code> 提供了专门的清理子命令，可以安全地移除各种缓存文件。</p>
<h3 id="基础清理最常用">
<a class="header-anchor" href="#%e5%9f%ba%e7%a1%80%e6%b8%85%e7%90%86%e6%9c%80%e5%b8%b8%e7%94%a8"></a>
基础清理（最常用）
</h3><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>conda clean -a
</span></span></code></pre></div><p><code>-a</code> 表示清理所有类型的缓存，包括：</p>
<ul>
<li>索引缓存（index cache）</li>
<li>锁定文件</li>
<li>未使用的包缓存（tarballs）</li>
<li>源代码包缓存</li>
</ul>
<h3 id="按类型清理">
<a class="header-anchor" href="#%e6%8c%89%e7%b1%bb%e5%9e%8b%e6%b8%85%e7%90%86"></a>
按类型清理
</h3><table>
	<thead>
			<tr>
					<th>选项</th>
					<th>含义</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><code>-i</code> / <code>--index-cache</code></td>
					<td>清除索引缓存</td>
			</tr>
			<tr>
					<td><code>-p</code> / <code>--packages</code></td>
					<td>清除未使用的包文件（从 <code>pkgs</code> 目录删除未链接到任何环境的包）</td>
			</tr>
			<tr>
					<td><code>-t</code> / <code>--tarballs</code></td>
					<td>清除下载的压缩包（<code>.tar.bz2</code> 或 <code>.conda</code>）</td>
			</tr>
			<tr>
					<td><code>-f</code> / <code>--force</code></td>
					<td>强制删除，无确认提示</td>
			</tr>
	</tbody>
</table>
<p>例如，只清除下载的压缩包：</p>
        
        <hr><p>本文2026-09-01首发于<a href='https://example.org/'>Edward's Blog</a>，最后修改于2026-09-01</p>]]>
      </description>
      
        <category>O&amp;M</category>
      
    </item>
    
  </channel>
</rss>
