{"id":117,"date":"2025-08-27T22:50:03","date_gmt":"2025-08-27T14:50:03","guid":{"rendered":"https:\/\/caoxunyi.cn\/?p=117"},"modified":"2025-10-01T02:18:26","modified_gmt":"2025-09-30T18:18:26","slug":"miniconda-%e7%b2%be%e5%87%86%e5%85%a5%e9%97%a8%ef%bc%9a%e4%bb%8e%e5%ae%89%e8%a3%85%e5%88%b0%e9%ab%98%e6%95%88%e7%8e%af%e5%a2%83%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/caoxunyi.cn\/index.php\/117\/","title":{"rendered":"Miniconda \u7cbe\u51c6\u5165\u95e8\uff1a\u4ece\u5b89\u88c5\u5230\u9ad8\u6548\u73af\u5883\u7ba1\u7406"},"content":{"rendered":"<h2>\u524d\u8a00\uff1a\u4e3a\u4f55\u9009\u62e9 Miniconda\uff1f<\/h2>\n<p>\u5728 Python \u7684\u4e16\u754c\u91cc\uff0c\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u548c Python \u7248\u672c\u662f\u4e00\u4e2a\u6c38\u6052\u7684\u6311\u6218\u3002\u201c\u4f9d\u8d56\u5730\u72f1\u201d\uff08Dependency Hell\uff09\u662f\u6bcf\u4e2a\u5f00\u53d1\u8005\u90fd\u53ef\u80fd\u9047\u5230\u7684\u5669\u68a6\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u6211\u4eec\u6709 Conda \u8fd9\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\u3002<\/p>\n<p><strong>Conda<\/strong> \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5305\u7ba1\u7406\u548c\u73af\u5883\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\uff1a<\/p>\n<ul>\n<li><strong>\u521b\u5efa\u9694\u79bb\u7684\u73af\u5883<\/strong>\uff1a\u6bcf\u4e2a\u9879\u76ee\u90fd\u53ef\u4ee5\u6709\u81ea\u5df1\u72ec\u7acb\u7684 Python \u7248\u672c\u548c\u5305\uff0c\u4e92\u4e0d\u5e72\u6270\u3002<\/li>\n<li><strong>\u8f7b\u677e\u7ba1\u7406\u5305<\/strong>\uff1a\u5b89\u88c5\u3001\u66f4\u65b0\u3001\u5220\u9664\u590d\u6742\u7684\u79d1\u5b66\u8ba1\u7b97\u5305\uff08\u5982 NumPy, PyTorch\uff09\u53d8\u5f97\u5f02\u5e38\u7b80\u5355\u3002<\/li>\n<\/ul>\n<p>\u800c <strong>Miniconda<\/strong> \u5219\u662f Conda \u7684\u4e00\u4e2a\u6700\u5c0f\u5316\u5b89\u88c5\u5668\u3002\u4e0e\u5305\u542b\u6570\u767e\u4e2a\u9884\u88c5\u5305\u7684 Anaconda \u4e0d\u540c\uff0cMiniconda \u53ea\u5305\u542b Conda \u53ca\u5176\u6838\u5fc3\u4f9d\u8d56\u3002\u8fd9\u7ed9\u4e86\u6211\u4eec\u6700\u5927\u7684\u81ea\u7531\u5ea6\u548c\u4e00\u4e2a\u5e72\u51c0\u7684\u8d77\u70b9\uff0c\u8ba9\u6211\u4eec\u53ea\u5b89\u88c5\u81ea\u5df1\u771f\u6b63\u9700\u8981\u7684\u4e1c\u897f\uff0c\u8fd9\u5b8c\u5168\u7b26\u5408\u201c\u4fdd\u6301\u7b80\u6d01\u201d\u7684\u54f2\u5b66\u3002<\/p>\n<p>\u8fd9\u7bc7\u6307\u5357\u5c06\u5e26\u4f60\u8d70\u5b8c\u4ece\u5b89\u88c5\u5230\u9ad8\u6548\u914d\u7f6e Miniconda \u7684\u6bcf\u4e00\u6b65\u3002<\/p>\n<hr \/>\n<h2>\u4e00\u3001\u5b89\u88c5 Miniconda<\/h2>\n<p>\u6211\u4eec\u5c06\u4f7f\u7528\u5b98\u65b9\u811a\u672c\u8fdb\u884c\u5b89\u88c5\uff0c\u8fd9\u662f\u6700\u901a\u7528\u3001\u6700\u63a8\u8350\u7684\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u6240\u6709 Linux \u53d1\u884c\u7248\u3001macOS \u548c Windows (WSL)\u3002<\/p>\n<h3>1. \u9488\u5bf9\u4e0d\u540c\u7cfb\u7edf\u4e0b\u8f7d\u5bf9\u5e94\u811a\u672c<\/h3>\n<p>\u9996\u5148\uff0c\u9700\u8981\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u82af\u7247\u67b6\u6784\u9009\u62e9\u6b63\u786e\u7684\u5b89\u88c5\u811a\u672c\u3002<\/p>\n<h4>WSL \/ Linux (x86_64)<\/h4>\n<p>\u6253\u5f00\u4f60\u7684 WSL \u6216 Linux \u7ec8\u7aef\uff0c\u4f7f\u7528 <code>curl<\/code> \u4e0b\u8f7d\u6700\u65b0\u7684 64 \u4f4d Linux \u5b89\u88c5\u811a\u672c\u3002<\/p>\n<pre><code class=\"lang-bash language-bash bash\"># \u9002\u7528\u4e8e WSL \u548c\u7edd\u5927\u591a\u6570 Linux \u670d\u52a1\u5668\/\u684c\u9762\u7cfb\u7edf\ncurl -O https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-Linux-x86_64.sh<\/code><\/pre>\n<h4>macOS<\/h4>\n<p>\u5bf9\u4e8e macOS\uff0c\u9996\u5148\u9700\u8981\u786e\u5b9a\u4f60\u7684 Mac \u82af\u7247\u7c7b\u578b\u3002\u6253\u5f00\u201c\u7ec8\u7aef\u201d (Terminal) \u5e94\u7528\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"lang-bash language-bash bash\">uname -m<\/code><\/pre>\n<ul>\n<li>\u5982\u679c\u7ed3\u679c\u662f <code>arm64<\/code>\uff0c\u5219\u4e3a <strong>Apple Silicon<\/strong> \u82af\u7247 (M1\/M2\/M3 \u7b49)\u3002<\/li>\n<li>\u5982\u679c\u7ed3\u679c\u662f <code>x86_64<\/code>\uff0c\u5219\u4e3a <strong>Intel<\/strong> \u82af\u7247\u3002<\/li>\n<\/ul>\n<p>\u7136\u540e\u6839\u636e\u4f60\u7684\u82af\u7247\u7c7b\u578b\uff0c\u6267\u884c\u5bf9\u5e94\u7684\u4e0b\u8f7d\u547d\u4ee4\u3002<\/p>\n<pre><code class=\"lang-bash language-bash bash\"># ----- macOS (Apple Silicon, arm64) \u7528\u6237\u8bf7\u8fd0\u884c: -----\ncurl -O https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-MacOSX-arm64.sh\n\n# ----- macOS (Intel, x86_64) \u7528\u6237\u8bf7\u8fd0\u884c: -----\ncurl -O https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-MacOSX-x86_64.sh<\/code><\/pre>\n<h3>2. \u8fd0\u884c\u5b89\u88c5\u811a\u672c<\/h3>\n<p>\u6267\u884c\u4f60\u521a\u521a\u4e0b\u8f7d\u597d\u7684 <code>.sh<\/code> \u811a\u672c\u6587\u4ef6\u3002\u8bf7\u6839\u636e\u4f60\u4e0b\u8f7d\u7684\u6587\u4ef6\u540d\u9009\u62e9\u5bf9\u5e94\u7684\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"lang-bash language-bash bash\"># \u5982\u679c\u662f WSL \/ Linux \u7cfb\u7edf\nbash Miniconda3-latest-Linux-x86_64.sh\n\n# \u5982\u679c\u662f macOS (Apple Silicon)\nbash Miniconda3-latest-MacOSX-arm64.sh\n\n# \u5982\u679c\u662f macOS (Intel)\nbash Miniconda3-latest-MacOSX-x86_64.sh<\/code><\/pre>\n<p>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u9700\u8981\uff1a<\/p>\n<ol>\n<li>\u6309 <strong>Enter<\/strong> \u9605\u8bfb\u8bb8\u53ef\u8bc1\u534f\u8bae\uff08\u6216\u6309 <code>q<\/code> \u8df3\u8fc7\uff09\u3002<\/li>\n<li>\u8f93\u5165 <code>yes<\/code> \u540c\u610f\u534f\u8bae\u3002<\/li>\n<li>\u786e\u8ba4\u5b89\u88c5\u8def\u5f84\uff08\u76f4\u63a5\u6309 <strong>Enter<\/strong> \u4f7f\u7528\u9ed8\u8ba4\u7684 <code>~\/miniconda3<\/code> \u5373\u53ef\uff09\u3002<\/li>\n<li>\u5f53\u88ab\u95ee\u53ca\u662f\u5426\u8981\u521d\u59cb\u5316 Conda (<code>conda init<\/code>) \u65f6\uff0c<strong>\u52a1\u5fc5\u8f93\u5165 <code>yes<\/code><\/strong>\u3002\u8fd9\u662f\u6700\u5173\u952e\u7684\u4e00\u6b65\uff0c\u5b83\u4f1a\u81ea\u52a8\u914d\u7f6e\u4f60\u7684 shell\uff0c\u8ba9\u4f60\u80fd\u76f4\u63a5\u4f7f\u7528 <code>conda<\/code> \u547d\u4ee4\u3002<\/li>\n<\/ol>\n<h3>3. \u6fc0\u6d3b\u914d\u7f6e<\/h3>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c<strong>\u5173\u95ed\u5e76\u91cd\u65b0\u6253\u5f00\u4f60\u7684\u7ec8\u7aef<\/strong>\u3002\u4f60\u4f1a\u770b\u5230\u7ec8\u7aef\u63d0\u793a\u7b26\u524d\u9762\u591a\u4e86\u4e00\u4e2a <code>(base)<\/code>\uff0c\u8fd9\u8868\u793a Conda \u5df2\u7ecf\u5b89\u88c5\u6210\u529f\uff0c\u5e76\u4e14\u4f60\u6b63\u5904\u4e8e\u5b83\u7684 <code>base<\/code>\uff08\u57fa\u7840\uff09\u73af\u5883\u4e2d\u3002<\/p>\n<pre><code class=\"lang-bash language-bash bash\"># \u91cd\u65b0\u6253\u5f00\u7ec8\u7aef\u540e\uff0c\u4f60\u4f1a\u770b\u5230\u8fd9\u6837\u7684\u63d0\u793a\u7b26\n(base) [your_user@your_host ~]$<\/code><\/pre>\n<hr \/>\n<h2>\u4e8c\u3001\u6838\u5fc3\uff1aConda \u73af\u5883\u7ba1\u7406<\/h2>\n<p>\u638c\u63e1\u73af\u5883\u7ba1\u7406\u662f\u4f7f\u7528 Conda \u7684\u7cbe\u9ad3\u6240\u5728\u3002\u8bf7\u7262\u8bb0\u4e00\u4e2a\u6700\u4f73\u5b9e\u8df5\uff1a<strong>\u4e0d\u8981\u5728 <code>base<\/code> \u73af\u5883\u4e2d\u5b89\u88c5\u5927\u91cf\u5305\uff0c\u4e3a\u4f60\u7684\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684\u65b0\u73af\u5883<\/strong>\u3002<\/p>\n<h3>1. \u521b\u5efa\u73af\u5883<\/h3>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a <code>my_project<\/code> \u4e14\u4f7f\u7528 Python 3.11 \u7684\u65b0\u73af\u5883\u3002<\/p>\n<pre><code class=\"lang-bash language-bash bash\">conda create --name my_project python=3.11<\/code><\/pre>\n<ul>\n<li><code>--name<\/code> \u53ef\u4ee5\u7f29\u5199\u4e3a <code>-n<\/code>\u3002<\/li>\n<li>\u4f60\u4e5f\u53ef\u4ee5\u5728\u521b\u5efa\u65f6\u5c31\u6307\u5b9a\u9700\u8981\u5b89\u88c5\u7684\u5305\uff1a\n<pre><code class=\"lang-bash language-bash bash\">conda create -n my_project python=3.11 numpy pandas jupyterlab<\/code><\/pre><\/li>\n<\/ul>\n<h3>2. \u6fc0\u6d3b\u4e0e\u9000\u51fa\u73af\u5883<\/h3>\n<ul>\n<li>\n<p><strong>\u6fc0\u6d3b\uff08\u8fdb\u5165\uff09\u73af\u5883<\/strong>\uff1a<\/p>\n<pre><code class=\"lang-bash language-bash bash\">conda activate my_project<\/code><\/pre>\n<p>\u6fc0\u6d3b\u540e\uff0c\u4f60\u7684\u7ec8\u7aef\u63d0\u793a\u7b26\u4f1a\u53d8\u4e3a <code>(my_project)<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u73af\u5883<\/strong>\uff1a<\/p>\n<pre><code class=\"lang-bash language-bash bash\">conda deactivate<\/code><\/pre>\n<p>\u9000\u51fa\u540e\uff0c\u4f60\u4f1a\u8fd4\u56de\u5230 <code>(base)<\/code> \u73af\u5883\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>3. \u7ba1\u7406\u73af\u5883\u4e2d\u7684\u5305<\/h3>\n<p>\u786e\u4fdd\u4f60\u5df2\u7ecf<strong>\u6fc0\u6d3b<\/strong>\u4e86\u76ee\u6807\u73af\u5883\u3002<\/p>\n<ul>\n<li><strong>\u5b89\u88c5\u5305<\/strong>\uff1a\n<pre><code class=\"lang-bash language-bash bash\">conda install scipy matplotlib<\/code><\/pre><\/li>\n<li><strong>\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5305<\/strong>\uff1a\n<pre><code class=\"lang-bash language-bash bash\">conda list<\/code><\/pre><\/li>\n<li><strong>\u5378\u8f7d\u5305<\/strong>\uff1a\n<pre><code class=\"lang-bash language-bash bash\">conda remove scipy<\/code><\/pre><\/li>\n<\/ul>\n<h3>4. \u67e5\u770b\u4e0e\u5220\u9664\u73af\u5883<\/h3>\n<ul>\n<li><strong>\u67e5\u770b\u6240\u6709\u5df2\u521b\u5efa\u7684\u73af\u5883<\/strong>\uff1a\n<pre><code class=\"lang-bash language-bash bash\">conda env list<\/code><\/pre><\/li>\n<li><strong>\u5f7b\u5e95\u5220\u9664\u4e00\u4e2a\u4e0d\u518d\u9700\u8981\u7684\u73af\u5883<\/strong>\uff1a\n<pre><code class=\"lang-bash language-bash bash\">conda env remove --name my_project<\/code><\/pre><\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e09\u3001\u4e2a\u6027\u5316\u914d\u7f6e\uff1a\u4e00\u4e2a\u6709\u7528\u7684\u6280\u5de7<\/h2>\n<p>\u5f88\u591a\u5f00\u53d1\u8005\uff08\u5305\u62ec\u6211\uff09\u4e0d\u559c\u6b22\u6bcf\u6b21\u6253\u5f00\u7ec8\u7aef\u90fd\u81ea\u52a8\u8fdb\u5165 <code>(base)<\/code> \u73af\u5883\u3002\u6211\u4eec\u5e0c\u671b\u53ea\u5728\u9700\u8981\u65f6\u624d\u624b\u52a8\u6fc0\u6d3b Conda\u3002<\/p>\n<p>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u7981\u6b62\u8fd9\u4e2a\u9ed8\u8ba4\u884c\u4e3a\uff1a<\/p>\n<pre><code class=\"lang-bash language-bash bash\">conda config --set auto_activate_base false<\/code><\/pre>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u662f<strong>\u6c38\u4e45\u751f\u6548<\/strong>\u7684\u3002\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u6253\u5f00\u4e00\u4e2a\u65b0\u7ec8\u7aef\uff0c\u4f60\u4f1a\u53d1\u73b0 <code>(base)<\/code> \u6d88\u5931\u4e86\uff0c\u4e00\u5207\u53c8\u6062\u590d\u4e86\u6e05\u723d\u3002\u5f53\u4f60\u9700\u8981\u4f7f\u7528 Conda \u65f6\uff0c\u53ea\u9700\u624b\u52a8 <code>conda activate &lt;\u4f60\u7684\u73af\u5883\u540d&gt;<\/code> \u5373\u53ef\u3002<\/p>\n<p>\u8fd9\u4e2a\u914d\u7f6e\u4f1a\u88ab\u5199\u5165\u4f60\u7684\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\u7684 <code>.condarc<\/code> \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u968f\u65f6\u624b\u52a8\u7f16\u8f91\u5b83\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u606d\u559c\u4f60\uff01\u73b0\u5728\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86 Miniconda \u7684\u6838\u5fc3\u7528\u6cd5\uff1a<\/p>\n<ol>\n<li><strong>\u6210\u529f\u5b89\u88c5<\/strong>\u5e76\u521d\u59cb\u5316\u4e86 Conda\u3002<\/li>\n<li>\u5b66\u4f1a\u4e86<strong>\u521b\u5efa\u3001\u6fc0\u6d3b\u548c\u7ba1\u7406<\/strong>\u72ec\u7acb\u7684\u9879\u76ee\u73af\u5883\u3002<\/li>\n<li>\u638c\u63e1\u4e86\u5728\u73af\u5883\u4e2d<strong>\u589e\u5220\u5305<\/strong>\u7684\u65b9\u6cd5\u3002<\/li>\n<li>\u5b66\u4f1a\u4e86<strong>\u4e2a\u6027\u5316\u914d\u7f6e<\/strong>\uff0c\u8ba9 Conda \u66f4\u7b26\u5408\u4f60\u7684\u4f7f\u7528\u4e60\u60ef\u3002<\/li>\n<\/ol>\n<p>\u59cb\u7ec8\u4e3a\u4f60\u7684\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684\u73af\u5883\uff0c\u8fd9\u662f\u901a\u5f80\u4e00\u4e2a\u5e72\u51c0\u3001\u53ef\u590d\u73b0\u3001\u65e0\u51b2\u7a81\u7684\u5f00\u53d1\u5de5\u4f5c\u6d41\u7684\u6700\u4f73\u8def\u5f84\u3002\u73b0\u5728\uff0c\u5f00\u59cb\u4eab\u53d7 Conda \u5e26\u6765\u7684\u4fbf\u5229\u5427\uff01<\/p>","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\uff1a\u4e3a\u4f55\u9009\u62e9 Miniconda\uff1f \u5728 Python \u7684\u4e16\u754c\u91cc\uff0c\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u548c Python \u7248\u672c\u662f\u4e00\u4e2a\u6c38\u6052\u7684\u6311\u6218\u3002\u201c\u4f9d\u8d56 &#8230;<\/p>","protected":false},"author":1,"featured_media":178,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[18,1],"tags":[20,21,22,19],"class_list":["post-117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-learn","tag-conda","tag-linux","tag-mac","tag-python"],"_links":{"self":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":2,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":170,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/117\/revisions\/170"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/media\/178"}],"wp:attachment":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}