{"id":1178611,"date":"2025-01-15T18:13:12","date_gmt":"2025-01-15T10:13:12","guid":{"rendered":""},"modified":"2025-01-15T18:13:16","modified_gmt":"2025-01-15T10:13:16","slug":"python%e5%a6%82%e4%bd%95%e8%b0%83%e7%94%a8anaconda%e7%9a%84%e5%8c%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1178611.html","title":{"rendered":"python\u5982\u4f55\u8c03\u7528anaconda\u7684\u5305"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25113230\/e86043c2-fd55-4547-aa04-803c3c226652.webp\" alt=\"python\u5982\u4f55\u8c03\u7528anaconda\u7684\u5305\" \/><\/p>\n<p><p> <strong>Python\u8c03\u7528Anaconda\u7684\u5305\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\uff1a\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528conda\u73af\u5883\u3001\u5229\u7528Jupyter Notebook\u6216Spyder\u3002<\/strong> \u5728\u8fd9\u4e9b\u65b9\u6cd5\u4e2d\uff0c<strong>\u4f7f\u7528conda\u73af\u5883<\/strong>\u662f\u6700\u63a8\u8350\u7684\u65b9\u5f0f\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u548c\u73af\u5883\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><h3>\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5728Windows\u4e0a\uff0cAnaconda\u5b89\u88c5\u76ee\u5f55\u901a\u5e38\u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u5982\u679c\u6ca1\u6709\u81ea\u52a8\u914d\u7f6e\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u6dfb\u52a0Anaconda\u7684\u5b89\u88c5\u8def\u5f84\u5230\u7cfb\u7edf\u7684PATH\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\uff0c\u53ef\u4ee5\u901a\u8fc7\u53f3\u952e\u201c\u6211\u7684\u7535\u8111\u201d\u6216\u8005\u201c\u6b64\u7535\u8111\u201d\uff0c\u7136\u540e\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u9009\u62e9\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u540d\u4e3a\u201cPath\u201d\u7684\u53d8\u91cf\uff0c\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u5c06Anaconda\u7684\u5b89\u88c5\u8def\u5f84\uff08\u4f8b\u5982<code>C:\\Users\\YourUsername\\Anaconda3<\/code>\uff09\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/li>\n<li>\u4fdd\u5b58\u8bbe\u7f6e\u5e76\u91cd\u542f\u4f60\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/li>\n<\/ol>\n<p><p>\u5728macOS\u548cLinux\u4e0a\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>.bashrc<\/code>\u6216<code>.zshrc<\/code>\u6587\u4ef6\u6765\u6dfb\u52a0\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/path\/to\/anaconda3\/bin:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u8fd0\u884c<code>source ~\/.bashrc<\/code>\u6216<code>source ~\/.zshrc<\/code>\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528Conda\u73af\u5883<\/h3>\n<\/p>\n<p><p><strong>Conda\u73af\u5883<\/strong>\u662fAnaconda\u7684\u4e00\u5927\u7279\u70b9\uff0c\u5b83\u5141\u8bb8\u4f60\u521b\u5efa\u548c\u7ba1\u7406\u591a\u4e2a\u72ec\u7acb\u7684\u73af\u5883\uff0c\u6bcf\u4e2a\u73af\u5883\u53ef\u4ee5\u6709\u4e0d\u540c\u7684Python\u7248\u672c\u548c\u5305\u96c6\u5408\u3002\u4f7f\u7528Conda\u73af\u5883\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982Anaconda Prompt\u6216\u7ec8\u7aef\uff09\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u73af\u5883\u5e76\u6307\u5b9aPython\u7248\u672c\uff1a\n<pre><code class=\"language-bash\">conda create --name myenv python=3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u6fc0\u6d3b\u65b0\u521b\u5efa\u7684\u73af\u5883\uff1a\n<pre><code class=\"language-bash\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728\u6fc0\u6d3b\u7684\u73af\u5883\u4e2d\u5b89\u88c5\u6240\u9700\u7684\u5305\uff1a\n<pre><code class=\"language-bash\">conda install numpy pandas matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u8fd0\u884c\u4f60\u7684Python\u811a\u672c\u6216\u542f\u52a8Python\u89e3\u91ca\u5668\uff1a\n<pre><code class=\"language-bash\">python myscript.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5728\u8fd9\u4e2a\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u81ea\u7531\u5730\u5b89\u88c5\u3001\u66f4\u65b0\u6216\u5220\u9664\u5305\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u73af\u5883\u3002\u8981\u9000\u51fa\u5f53\u524d\u73af\u5883\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5229\u7528Jupyter Notebook\u6216Spyder<\/h3>\n<\/p>\n<p><p>Anaconda\u9644\u5e26\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u5982Jupyter Notebook\u548cSpyder\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528Anaconda\u73af\u5883\u4e2d\u7684\u5305\u3002<\/p>\n<\/p>\n<p><h4>Jupyter Notebook<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00Anaconda Navigator\u3002<\/li>\n<li>\u542f\u52a8Jupyter Notebook\u3002<\/li>\n<li>\u5728\u65b0\u5f00\u7684\u7f51\u9875\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7b14\u8bb0\u672c\u3002<\/li>\n<li>\u5728\u7b14\u8bb0\u672c\u4e2d\u76f4\u63a5\u5bfc\u5165\u4f60\u9700\u8981\u7684\u5305\u5e76\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p><h4>Spyder<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00Anaconda Navigator\u3002<\/li>\n<li>\u542f\u52a8Spyder\u3002<\/li>\n<li>\u5728Spyder\u7684\u7f16\u8f91\u5668\u4e2d\u7f16\u5199\u4ee3\u7801\uff0c\u76f4\u63a5\u5bfc\u5165Anaconda\u73af\u5883\u4e2d\u7684\u5305\u3002<\/li>\n<\/ol>\n<p><h3>\u5b89\u88c5\u548c\u7ba1\u7406\u5305<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Anaconda\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>conda<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u548c\u7ba1\u7406\u5305\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><h4>\u5b89\u88c5\u5305<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528<code>conda install<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u5305\uff0c\u4f8b\u5982\u5b89\u88c5SciPy\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install scipy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u66f4\u65b0\u5305<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda update<\/code>\u547d\u4ee4\u6765\u66f4\u65b0\u5305\uff0c\u4f8b\u5982\u66f4\u65b0Pandas\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda update pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5220\u9664\u5305<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda remove<\/code>\u547d\u4ee4\u6765\u5220\u9664\u5305\uff0c\u4f8b\u5982\u5220\u9664Matplotlib\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda remove matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u67e5\u770b\u5df2\u5b89\u88c5\u5305<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda list<\/code>\u547d\u4ee4\u6765\u67e5\u770b\u5f53\u524d\u73af\u5883\u4e2d\u5df2\u5b89\u88c5\u7684\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u521b\u5efa\u548c\u7ba1\u7406\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u4e0d\u540c\u9879\u76ee\u53ef\u80fd\u9700\u8981\u4e0d\u540c\u7684\u4f9d\u8d56\u5305\u548cPython\u7248\u672c\uff0c\u4f7f\u7528Conda\u73af\u5883\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u8fd9\u4e9b\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><h4>\u521b\u5efa\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda create<\/code>\u547d\u4ee4\u6765\u521b\u5efa\u65b0\u7684\u73af\u5883\uff0c\u4f8b\u5982\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>data_science<\/code>\u7684\u73af\u5883\u5e76\u5b89\u88c5\u5e38\u7528\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create --name data_science python=3.9 numpy pandas matplotlib scipy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u6fc0\u6d3b\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda activate<\/code>\u547d\u4ee4\u6765\u6fc0\u6d3b\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate data_science<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5207\u6362\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5728\u591a\u4e2a\u73af\u5883\u4e4b\u95f4\u5207\u6362\uff0c\u4f7f\u7528<code>conda deactivate<\/code>\u6765\u9000\u51fa\u5f53\u524d\u73af\u5883\uff0c\u7136\u540e\u4f7f\u7528<code>conda activate<\/code>\u6765\u6fc0\u6d3b\u53e6\u4e00\u4e2a\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h4>\u5220\u9664\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda remove --name<\/code>\u547d\u4ee4\u6765\u5220\u9664\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda remove --name data_science --all<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5171\u4eab\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u56e2\u961f\u5408\u4f5c\u4e2d\uff0c\u786e\u4fdd\u6bcf\u4e2a\u4eba\u7684\u5f00\u53d1\u73af\u5883\u4e00\u81f4\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7<code>conda<\/code>\u547d\u4ee4\u5bfc\u51fa\u548c\u5bfc\u5165\u73af\u5883\u914d\u7f6e\u6587\u4ef6\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<\/p>\n<p><h4>\u5bfc\u51fa\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda env export<\/code>\u547d\u4ee4\u6765\u5bfc\u51fa\u5f53\u524d\u73af\u5883\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda env export &gt; environment.yml<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5bfc\u5165\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda env create<\/code>\u547d\u4ee4\u6765\u57fa\u4e8e\u914d\u7f6e\u6587\u4ef6\u521b\u5efa\u65b0\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda env create -f environment.yml<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4f7f\u7528Pip\u5b89\u88c5\u5305<\/h3>\n<\/p>\n<p><p>\u867d\u7136<code>conda<\/code>\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5305\u7ba1\u7406\u529f\u80fd\uff0c\u4f46\u662f\u6709\u65f6\u5019\u4f60\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u4e00\u4e9b<code>conda<\/code>\u4ed3\u5e93\u4e2d\u6ca1\u6709\u7684\u5305\uff0c\u8fd9\u65f6\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u6765\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h4>\u5728Conda\u73af\u5883\u4e2d\u4f7f\u7528Pip<\/h4>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u7684Conda\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<code>pip<\/code>\u6765\u5b89\u88c5\u5305\uff0c\u4f8b\u5982\u5b89\u88c5<code>requests<\/code>\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u4f7f\u7528Pip\u548cConda\u7684\u6700\u4f73\u5b9e\u8df5<\/h4>\n<\/p>\n<p><p>\u5728\u4e00\u4e2a\u73af\u5883\u4e2d\u540c\u65f6\u4f7f\u7528<code>pip<\/code>\u548c<code>conda<\/code>\u5b89\u88c5\u5305\u65f6\uff0c\u5efa\u8bae\u5148\u4f7f\u7528<code>conda<\/code>\u5b89\u88c5\u5c3d\u53ef\u80fd\u591a\u7684\u5305\uff0c\u518d\u4f7f\u7528<code>pip<\/code>\u5b89\u88c5<code>conda<\/code>\u4e2d\u6ca1\u6709\u7684\u5305\u3002\u8fd9\u662f\u56e0\u4e3a<code>conda<\/code>\u548c<code>pip<\/code>\u7684\u5305\u7ba1\u7406\u673a\u5236\u4e0d\u540c\uff0c\u540c\u65f6\u4f7f\u7528\u53ef\u80fd\u4f1a\u5bfc\u81f4\u73af\u5883\u7684\u4e0d\u7a33\u5b9a\u3002<\/p>\n<\/p>\n<p><h3>\u89e3\u51b3\u4f9d\u8d56\u51b2\u7a81<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Conda\u5b89\u88c5\u5305\u65f6\uff0c\u6709\u65f6\u5019\u4f1a\u9047\u5230\u4f9d\u8d56\u51b2\u7a81\u7684\u95ee\u9898\u3002Conda\u4f1a\u5c1d\u8bd5\u89e3\u51b3\u8fd9\u4e9b\u51b2\u7a81\uff0c\u4f46\u6709\u65f6\u9700\u8981\u624b\u52a8\u5e72\u9884\u3002<\/p>\n<\/p>\n<p><h4>\u67e5\u770b\u51b2\u7a81\u4fe1\u606f<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>conda install<\/code>\u547d\u4ee4\u65f6\uff0c\u5982\u679c\u9047\u5230\u4f9d\u8d56\u51b2\u7a81\uff0cConda\u4f1a\u63d0\u4f9b\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u8fd9\u4e9b\u4fe1\u606f\u6765\u8c03\u6574\u5b89\u88c5\u5305\u7684\u7248\u672c\u6216\u987a\u5e8f\u3002<\/p>\n<\/p>\n<p><h4>\u5f3a\u5236\u5b89\u88c5\u7279\u5b9a\u7248\u672c<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u786e\u5b9a\u9700\u8981\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528<code>conda install<\/code>\u547d\u4ee4\u6307\u5b9a\u7248\u672c\u53f7\uff0c\u4f8b\u5982\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684TensorFlow\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install tensorflow=2.4.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4f9d\u8d56\u51b2\u7a81\u96be\u4ee5\u89e3\u51b3\uff0c\u53ef\u4ee5\u8003\u8651\u521b\u5efa\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u4ee5\u907f\u514d\u4e0e\u73b0\u6709\u73af\u5883\u7684\u4f9d\u8d56\u51b2\u7a81\u3002<\/p>\n<\/p>\n<p><h3>\u9ad8\u7ea7\u7528\u6cd5<\/h3>\n<\/p>\n<p><h4>\u81ea\u5b9a\u4e49\u9891\u9053<\/h4>\n<\/p>\n<p><p>Conda\u9ed8\u8ba4\u4f7f\u7528Anaconda\u5b98\u65b9\u7684\u5305\u4ed3\u5e93\uff0c\u4f46\u4f60\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u81ea\u5b9a\u4e49\u7684\u9891\u9053\uff08\u5982Conda Forge\uff09\u6765\u83b7\u53d6\u66f4\u591a\u7684\u5305\u3002<\/p>\n<\/p>\n<p><p>\u6dfb\u52a0Conda Forge\u9891\u9053\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda config --add channels conda-forge<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8bbe\u7f6eConda Forge\u4e3a\u9ed8\u8ba4\u9891\u9053\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda config --set channel_priority strict<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u79bb\u7ebf\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u5728\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e0b\u8f7d\u5305\u7684tarball\u6587\u4ef6\u5e76\u4f7f\u7528<code>conda install<\/code>\u547d\u4ee4\u8fdb\u884c\u79bb\u7ebf\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4e0b\u8f7dNumPy\u7684tarball\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install \/path\/to\/numpy-1.19.2-py38h54aff64_0.tar.bz2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u7efc\u5408\u793a\u4f8b<\/h3>\n<\/p>\n<p><p>\u5047\u8bbe\u4f60\u6b63\u5728\u8fdb\u884c\u4e00\u4e2a\u6570\u636e\u5206\u6790\u9879\u76ee\uff0c\u9700\u8981\u4f7f\u7528Pandas\u3001NumPy\u548cMatplotlib\u5e93\u3002\u4f60\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u6765\u914d\u7f6e\u4f60\u7684\u5f00\u53d1\u73af\u5883\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Conda\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create --name data_analysis python=3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u6fc0\u6d3b\u65b0\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate data_analysis<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5\u6240\u9700\u7684\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install pandas numpy matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u7f16\u5199\u5e76\u8fd0\u884c\u4f60\u7684Python\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u636e\u96c6<\/strong><\/h2>\n<p>data = {<\/p>\n<p>    &#39;A&#39;: np.random.rand(10),<\/p>\n<p>    &#39;B&#39;: np.random.rand(10),<\/p>\n<p>    &#39;C&#39;: np.random.rand(10)<\/p>\n<p>}<\/p>\n<h2><strong>\u521b\u5efaDataFrame<\/strong><\/h2>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316<\/strong><\/h2>\n<p>print(df.describe())<\/p>\n<p>df.plot(kind=&#39;bar&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u548c\u7ba1\u7406\u9879\u76ee\u6240\u9700\u7684\u73af\u5883\uff0c\u5e76\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u5305\u7684\u4e00\u81f4\u6027\u548c\u517c\u5bb9\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528Anaconda\u6765\u7ba1\u7406Python\u5305\u548c\u73af\u5883\uff0c\u53ef\u4ee5\u6781\u5927\u5730\u7b80\u5316\u5f00\u53d1\u8fc7\u7a0b\uff0c\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002<strong>\u901a\u8fc7\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528Conda\u73af\u5883\u548c\u5229\u7528Jupyter Notebook\u6216Spyder\u7b49\u65b9\u5f0f<\/strong>\uff0c\u4f60\u53ef\u4ee5\u65b9\u4fbf\u5730\u8c03\u7528Anaconda\u7684\u5305\u8fdb\u884c\u5f00\u53d1\u3002\u5efa\u8bae\u4f7f\u7528Conda\u73af\u5883\u6765\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ee5\u786e\u4fdd\u73af\u5883\u7684\u72ec\u7acb\u6027\u548c\u7a33\u5b9a\u6027\u3002\u540c\u65f6\uff0c\u638c\u63e1Conda\u7684\u9ad8\u7ea7\u7528\u6cd5\u5982\u81ea\u5b9a\u4e49\u9891\u9053\u548c\u79bb\u7ebf\u5b89\u88c5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u5404\u79cd\u573a\u666f\u4e0b\u7075\u6d3b\u5e94\u5bf9\u5f00\u53d1\u9700\u6c42\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u786e\u8ba4Anaconda\u73af\u5883\u4e2d\u7684\u5df2\u5b89\u88c5\u5305\uff1f<\/strong><br \/>\u8981\u786e\u8ba4Anaconda\u73af\u5883\u4e2d\u5df2\u5b89\u88c5\u7684\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528Anaconda Navigator\u6216\u547d\u4ee4\u884c\u3002\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u8f93\u5165<code>conda list<\/code>\u547d\u4ee4\uff0c\u8fd9\u5c06\u663e\u793a\u5f53\u524d\u73af\u5883\u4e2d\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5305\u53ca\u5176\u7248\u672c\u4fe1\u606f\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u67e5\u770b\u6240\u9700\u5305\u662f\u5426\u5df2\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Anaconda\u4e2d\u521b\u5efa\u65b0\u73af\u5883\u5e76\u5b89\u88c5\u7279\u5b9a\u7684Python\u5305\uff1f<\/strong><br \/>\u5728Anaconda\u4e2d\u521b\u5efa\u65b0\u73af\u5883\u975e\u5e38\u7b80\u5355\u3002\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<code>conda create --name myenv python=3.9<\/code>\u6765\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyenv\u201d\u7684\u73af\u5883\uff0c\u5e76\u6307\u5b9aPython\u7248\u672c\u3002\u521b\u5efa\u540e\uff0c\u6fc0\u6d3b\u73af\u5883\u53ef\u4ee5\u4f7f\u7528<code>conda activate myenv<\/code>\uff0c\u63a5\u7740\u4f7f\u7528<code>conda install package_name<\/code>\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684\u5305\u3002<\/p>\n<p><strong>\u5982\u679c\u5728Python\u4e2d\u51fa\u73b0\u627e\u4e0d\u5230Anaconda\u5305\u7684\u9519\u8bef\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u9047\u5230\u627e\u4e0d\u5230Anaconda\u5305\u7684\u60c5\u51b5\uff0c\u9996\u5148\u9700\u8981\u786e\u8ba4\u662f\u5426\u5df2\u6fc0\u6d3b\u6b63\u786e\u7684Anaconda\u73af\u5883\u3002\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>conda info --envs<\/code>\u67e5\u770b\u5f53\u524d\u73af\u5883\u3002\u82e5\u73af\u5883\u5df2\u6fc0\u6d3b\u4f46\u4ecd\u6709\u95ee\u9898\uff0c\u53ef\u80fd\u9700\u8981\u68c0\u67e5\u5305\u662f\u5426\u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\uff0c\u6216\u8005\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5\u8be5\u5305\u6765\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8c03\u7528Anaconda\u7684\u5305\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\uff1a\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528conda\u73af\u5883\u3001\u5229\u7528Jupyter [&hellip;]","protected":false},"author":3,"featured_media":1178620,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1178611"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1178611"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1178611\/revisions"}],"predecessor-version":[{"id":1178623,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1178611\/revisions\/1178623"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1178620"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1178611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1178611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1178611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}