{"id":235,"date":"2025-04-05T20:32:27","date_gmt":"2025-04-05T12:32:27","guid":{"rendered":"http:\/\/47.100.31.79:8080\/?p=235"},"modified":"2025-04-05T20:37:06","modified_gmt":"2025-04-05T12:37:06","slug":"anaconda%e7%9b%b8%e5%85%b3","status":"publish","type":"post","link":"https:\/\/boki.shifengzhi.top\/?p=235","title":{"rendered":"Anaconda\u76f8\u5173"},"content":{"rendered":"<h2>conda\u95ee\u9898<\/h2>\n<p>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u548c<code>conda init powershell<\/code>\u4e4b\u540e\uff0cconda\u83ab\u540d\u5c31\u4e0d\u80fd\u7528\u4e86\uff0c\u56e0\u6b64\u60f3\u5230\u5c1d\u8bd5\u5b89\u88c5\u5b8c\u76f4\u63a5\u4f7f\u7528powershell\u522b\u540d\u673a\u5236\u5bf9\u5b9e\u9645\u7684conda.exe\u76ee\u5f55\u8fdb\u884c\u53d6\u522b\u540d<\/p>\n<h3>\u6c38\u4e45\u8bbe\u7f6e\u522b\u540d<\/h3>\n<pre><code class=\"language-powershell\">Add-Content -Path $PROFILE -Value &quot;`nSet-Alias -Name conda -Value `&quot;D:\\Anaconda3\\anaconda3\\Scripts\\conda.exe`&quot;&quot;<\/code><\/pre>\n<h3>\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6<\/h3>\n<pre><code class=\"language-powershell\">. $PROFILE<\/code><\/pre>\n<h3>\u9a8c\u8bc1\u522b\u540d\u662f\u5426\u751f\u6548<\/h3>\n<pre><code class=\"language-powershell\">Get-Alias conda<\/code><\/pre>\n<p>\u6216<\/p>\n<pre><code class=\"language-powershell\">conda --version<\/code><\/pre>\n<h1>Conda \u5e38\u7528\u547d\u4ee4\u5927\u5168<\/h1>\n<p>Conda \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5305\u7ba1\u7406\u548c\u73af\u5883\u7ba1\u7406\u7cfb\u7edf\uff0c\u5e38\u7528\u4e8e Python \u548c R \u8bed\u8a00\u7684\u4f9d\u8d56\u7ba1\u7406\u3002\u4ee5\u4e0b\u662f conda \u7684\u5e38\u7528\u547d\u4ee4\u5206\u7c7b\u6574\u7406\uff1a<\/p>\n<h2>\u73af\u5883\u7ba1\u7406<\/h2>\n<h3>\u521b\u5efa\u73af\u5883<\/h3>\n<pre><code class=\"language-bash\">conda create -n myenv                 # \u521b\u5efa\u540d\u4e3a myenv \u7684\u65b0\u73af\u5883\nconda create -n myenv python=3.8      # \u521b\u5efa\u6307\u5b9a Python \u7248\u672c\u7684\u73af\u5883\nconda create -n myenv numpy scipy      # \u521b\u5efa\u73af\u5883\u5e76\u5b89\u88c5\u6307\u5b9a\u5305\nconda create --clone myenv --name myenv_copy  # \u514b\u9686\u73af\u5883<\/code><\/pre>\n<h3>\u6fc0\u6d3b\/\u505c\u7528\u73af\u5883<\/h3>\n<pre><code class=\"language-bash\">conda activate myenv      # \u6fc0\u6d3b\u73af\u5883 (Windows\/Linux\/macOS)\nconda deactivate          # \u505c\u7528\u5f53\u524d\u73af\u5883<\/code><\/pre>\n<h3>\u5217\u51fa\u73af\u5883<\/h3>\n<pre><code class=\"language-bash\">conda env list            # \u5217\u51fa\u6240\u6709\u73af\u5883\nconda info --envs         # \u540c\u4e0a\uff0c\u5217\u51fa\u6240\u6709\u73af\u5883<\/code><\/pre>\n<h3>\u5220\u9664\u73af\u5883<\/h3>\n<pre><code class=\"language-bash\">conda env remove -n myenv  # \u5220\u9664\u6307\u5b9a\u73af\u5883\nconda remove --name myenv --all  # \u540c\u4e0a<\/code><\/pre>\n<h3>\u5bfc\u51fa\/\u5bfc\u5165\u73af\u5883<\/h3>\n<pre><code class=\"language-bash\">conda env export &gt; environment.yml       # \u5bfc\u51fa\u5f53\u524d\u73af\u5883\u914d\u7f6e\nconda env create -f environment.yml     # \u4ece\u6587\u4ef6\u521b\u5efa\u73af\u5883\nconda env update -f environment.yml      # \u66f4\u65b0\u5f53\u524d\u73af\u5883<\/code><\/pre>\n<h2>\u5305\u7ba1\u7406<\/h2>\n<h3>\u5b89\u88c5\u5305<\/h3>\n<pre><code class=\"language-bash\">conda install numpy         # \u5b89\u88c5\u6700\u65b0\u7248 numpy\nconda install numpy=1.19.2  # \u5b89\u88c5\u6307\u5b9a\u7248\u672c\nconda install -c conda-forge package_name  # \u4ece\u7279\u5b9a\u9891\u9053\u5b89\u88c5<\/code><\/pre>\n<h3>\u66f4\u65b0\u5305<\/h3>\n<pre><code class=\"language-bash\">conda update numpy         # \u66f4\u65b0\u5355\u4e2a\u5305\nconda update --all         # \u66f4\u65b0\u6240\u6709\u5305<\/code><\/pre>\n<h3>\u79fb\u9664\u5305<\/h3>\n<pre><code class=\"language-bash\">conda remove numpy         # \u79fb\u9664\u5305<\/code><\/pre>\n<h3>\u641c\u7d22\u5305<\/h3>\n<pre><code class=\"language-bash\">conda search numpy         # \u641c\u7d22\u5305\nconda search &quot;numpy&gt;=1.20&quot; # \u641c\u7d22\u7279\u5b9a\u7248\u672c<\/code><\/pre>\n<h3>\u5217\u51fa\u5df2\u5b89\u88c5\u5305<\/h3>\n<pre><code class=\"language-bash\">conda list                # \u5217\u51fa\u5f53\u524d\u73af\u5883\u6240\u6709\u5305\nconda list -n myenv       # \u5217\u51fa\u6307\u5b9a\u73af\u5883\u7684\u5305<\/code><\/pre>\n<h2>\u9891\u9053\u7ba1\u7406<\/h2>\n<pre><code class=\"language-bash\">conda config --add channels conda-forge  # \u6dfb\u52a0\u9891\u9053\nconda config --remove channels conda-forge  # \u79fb\u9664\u9891\u9053\nconda config --show channels            # \u663e\u793a\u5f53\u524d\u9891\u9053\nconda config --set channel_priority strict  # \u8bbe\u7f6e\u9891\u9053\u4f18\u5148\u7ea7<\/code><\/pre>\n<h2>\u7cfb\u7edf\u4fe1\u606f<\/h2>\n<pre><code class=\"language-bash\">conda info               # \u663e\u793aconda\u4fe1\u606f\nconda --version          # \u663e\u793aconda\u7248\u672c\nconda list --revisions   # \u663e\u793a\u73af\u5883\u4fee\u6539\u5386\u53f2\nconda clean --all        # \u6e05\u7406\u7f13\u5b58\u548c\u672a\u4f7f\u7528\u7684\u5305<\/code><\/pre>\n<h2>\u5b9e\u7528\u6280\u5de7<\/h2>\n<ol>\n<li>\n<p><strong>\u5feb\u901f\u521b\u5efaJupyter\u5185\u6838<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">conda install ipykernel\npython -m ipykernel install --user --name myenv --display-name \"Python (myenv)\"<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u5305\u4f9d\u8d56\u5173\u7cfb<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">conda repoquery depends numpy  # \u67e5\u770bnumpy\u7684\u4f9d\u8d56\nconda repoquery whoneeds numpy # \u67e5\u770b\u54ea\u4e9b\u5305\u4f9d\u8d56numpy<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u8de8\u5e73\u53f0\u5171\u4eab\u73af\u5883<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">conda env export --from-history > environment.yml  # \u53ea\u5bfc\u51fa\u663e\u5f0f\u5b89\u88c5\u7684\u5305<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u5feb\u901f\u590d\u5236\u73af\u5883<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">conda create --name new_env --clone old_env<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u4fee\u590d\u635f\u574f\u7684\u73af\u5883<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">conda update --all\nconda clean --all<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u8bb0\u4f4f\uff0c\u4f7f\u7528 conda \u65f6\u6700\u597d\u603b\u662f\u5148\u6fc0\u6d3b\u76ee\u6807\u73af\u5883\u518d\u8fdb\u884c\u64cd\u4f5c\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5728\u9519\u8bef\u7684\u73af\u5883\u4e2d\u5b89\u88c5\u6216\u5220\u9664\u5305\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>conda\u95ee\u9898 \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u548cconda init powershell\u4e4b\u540e\uff0cconda\u83ab\u540d\u5c31\u4e0d\u80fd\u7528\u4e86\uff0c\u56e0\u6b64\u60f3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[29],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-28","tag-conda"],"_links":{"self":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=235"}],"version-history":[{"count":3,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":238,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions\/238"}],"wp:attachment":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}