{"id":964034,"date":"2024-12-27T04:24:22","date_gmt":"2024-12-26T20:24:22","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/964034.html"},"modified":"2024-12-27T04:24:23","modified_gmt":"2024-12-26T20:24:23","slug":"%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85%e6%8c%87%e5%ae%9a%e7%89%88%e6%9c%acpython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/964034.html","title":{"rendered":"\u5982\u4f55\u5b89\u88c5\u6307\u5b9a\u7248\u672cpython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24181039\/daa6dc2d-bda4-4f07-8b0e-05c8dfbc45e5.webp\" alt=\"\u5982\u4f55\u5b89\u88c5\u6307\u5b9a\u7248\u672cpython\" \/><\/p>\n<p><p> <strong>\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u3001\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/strong> \u5176\u4e2d\uff0c\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177\u662f\u6700\u4e3a\u65b9\u4fbf\u548c\u7075\u6d3b\u7684\u65b9\u5f0f\u4e4b\u4e00\u3002\u63a5\u4e0b\u6765\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e00\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4e0b\u8f7d\u6307\u5b9a\u7248\u672c\u7684Python<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u5b89\u88c5\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u4ecePython\u5b98\u7f51\u6216\u5176\u4ed6\u53ef\u4fe1\u6765\u6e90\u4e0b\u8f7d\u6240\u9700\u7684Python\u7248\u672c\u3002Python\u5b98\u7f51\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E6%8F%90%E4%BE%9B%E4%BA%86%E6%89%80%E6%9C%89%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC%E7%9A%84%E4%B8%8B%E8%BD%BD%EF%BC%8C%E7%94%A8%E6%88%B7%E5%8F%AF%E4%BB%A5%E6%A0%B9%E6%8D%AE%E9%9C%80%E6%B1%82%E9%80%89%E6%8B%A9%E7%89%B9%E5%AE%9A%E7%89%88%E6%9C%AC%E3%80%82\">https:\/\/www.python.org\/\uff09\u63d0\u4f9b\u4e86\u6240\u6709\u5386\u53f2\u7248\u672c\u7684\u4e0b\u8f7d\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u9009\u62e9\u7279\u5b9a\u7248\u672c\u3002<\/a><\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbf\u95ee\u5b98\u7f51\u5e76\u9009\u62e9\u7248\u672c<\/strong>\uff1a\u8fdb\u5165Python\u5b98\u7f51\u4e0b\u8f7d\u9875\u9762\uff0c\u627e\u5230\u201cDownloads\u201d\u90e8\u5206\u3002\u5728\u8fd9\u4e2a\u9875\u9762\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u6700\u65b0\u7684Python\u7248\u672c\u4ee5\u53ca\u5386\u53f2\u7248\u672c\uff0c\u9009\u62e9\u4f60\u9700\u8981\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u64cd\u4f5c\u7cfb\u7edf<\/strong>\uff1a\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff08Windows\u3001macOS\u3001Linux\u7b49\uff09\u9009\u62e9\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u3002\u901a\u5e38\u4f1a\u6709\u591a\u79cd\u683c\u5f0f\u53ef\u4f9b\u9009\u62e9\uff0c\u5982Windows\u7684.exe\u6587\u4ef6\uff0cmacOS\u7684.pkg\u6587\u4ef6\uff0c\u6216Linux\u7684\u6e90\u4ee3\u7801.tar.gz\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b89\u88c5\u5305<\/strong>\uff1a\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u82e5\u662f\u538b\u7f29\u6587\u4ef6\uff0c\u9700\u5148\u8fdb\u884c\u89e3\u538b\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u901a\u5e38\u76f4\u63a5\u8fd0\u884c.exe\u6587\u4ef6\u5373\u53ef\u3002\u5bf9\u4e8emacOS\u548cLinux\u7528\u6237\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u547d\u4ee4\u884c\u6765\u89e3\u538b\u548c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u591a\u4e2aPython\u7248\u672c\u4e4b\u95f4\u5207\u6362\uff0c\u4e5f\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\u4e0d\u540c\u7684\u7248\u672c\u3002\u5e38\u7528\u7684Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\u6709pyenv\u548cAnaconda\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528pyenv<\/strong><\/p>\n<\/p>\n<p><p>pyenv\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5b89\u88c5\u548c\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u5b89\u88c5pyenv<\/strong>\uff1a\u5728Linux\u548cmacOS\u4e0a\u53ef\u4ee5\u901a\u8fc7Homebrew\u6216\u76f4\u63a5\u4f7f\u7528git\u547d\u4ee4\u5b89\u88c5\u3002\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528pyenv-win\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pyenv\u5b89\u88c5\u6307\u5b9a\u7248\u672c<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u547d\u4ee4<code>pyenv install &lt;version&gt;<\/code>\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\u3002\u4f8b\u5982\uff1a<code>pyenv install 3.8.10<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5207\u6362Python\u7248\u672c<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pyenv global &lt;version&gt;<\/code>\u5207\u6362\u5168\u5c40\u4f7f\u7528\u7684Python\u7248\u672c\uff0c\u6216\u4f7f\u7528<code>pyenv local &lt;version&gt;<\/code>\u4e3a\u5f53\u524d\u9879\u76ee\u8bbe\u7f6e\u7279\u5b9a\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Anaconda<\/strong><\/p>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684Python\u53d1\u884c\u7248\uff0c\u5185\u7f6e\u4e86\u4e30\u5bcc\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u540c\u65f6\u4e5f\u63d0\u4f9b\u4e86\u7248\u672c\u7ba1\u7406\u529f\u80fd\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u4e0b\u8f7d\u5e76\u5b89\u88c5Anaconda<\/strong>\uff1a\u8bbf\u95eeAnaconda\u5b98\u7f51\uff0c\u4e0b\u8f7d\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\uff0c\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u73af\u5883\u5e76\u5b89\u88c5\u6307\u5b9a\u7248\u672c<\/strong>\uff1a\u4f7f\u7528\u547d\u4ee4<code>conda create -n &lt;env_name&gt; python=&lt;version&gt;<\/code>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u73af\u5883\uff0c\u5e76\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python\u3002\u4f8b\u5982\uff1a<code>conda create -n myenv python=3.7<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u73af\u5883<\/strong>\uff1a\u4f7f\u7528<code>conda activate &lt;env_name&gt;<\/code>\u6fc0\u6d3b\u8be5\u73af\u5883\uff0c\u4fbf\u53ef\u4ee5\u5728\u5176\u4e2d\u4f7f\u7528\u6307\u5b9a\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8cPython\u540e\uff0c\u901a\u5e38\u9700\u8981\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Python\u547d\u4ee4\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7cfb\u7edf\u5c5e\u6027\uff0c\u8fdb\u5165\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e2d\u627e\u5230\u201cPath\u201d\u53d8\u91cf\uff0c\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u5c06Python\u5b89\u88c5\u76ee\u5f55\u548cScripts\u76ee\u5f55\u6dfb\u52a0\u5230Path\u4e2d\uff0c\u4f8b\u5982\uff1aC:\\Python39\u548cC:\\Python39\\Scripts\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>macOS\u548cLinux<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u7f16\u8f91\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\u7684.bashrc\u6216.zshrc\u6587\u4ef6\u3002<\/li>\n<li>\u6dfb\u52a0\u5982\u4e0b\u884c\uff1a<code>export PATH=&quot;\/path\/to\/python:$PATH&quot;<\/code>\uff0c\u5c06\u201c\/path\/to\/python\u201d\u66ff\u6362\u4e3a\u5b9e\u9645\u7684Python\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<li>\u4fdd\u5b58\u6587\u4ef6\u540e\uff0c\u8fd0\u884c<code>source ~\/.bashrc<\/code>\u6216<code>source ~\/.zshrc<\/code>\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528\u6307\u5b9a\u7248\u672c\u7684Python\u4e86\u3002\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u9ad8\u6548\u7387\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u540c\u65f6\u7ba1\u7406\u591a\u4e2aPython\u9879\u76ee\u7684\u60c5\u51b5\u4e0b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u6211\u9879\u76ee\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u5728\u9009\u62e9Python\u7248\u672c\u65f6\uff0c\u8003\u8651\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u548c\u517c\u5bb9\u6027\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u67d0\u4e9b\u5e93\u6216\u6846\u67b6\u53ef\u80fd\u53ea\u652f\u6301\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u56e0\u6b64\u6700\u597d\u67e5\u9605\u9879\u76ee\u6587\u6863\u6216\u5e93\u7684\u5b98\u65b9\u7f51\u7ad9\uff0c\u4ee5\u786e\u4fdd\u6240\u9009\u7248\u672c\u53ef\u4ee5\u4e0e\u6240\u6709\u5fc5\u8981\u7684\u4f9d\u8d56\u9879\u534f\u540c\u5de5\u4f5c\u3002\u6b64\u5916\uff0c\u4f7f\u7528Python\u7684\u957f\u671f\u652f\u6301\uff08LTS\uff09\u7248\u672c\u4e5f\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\uff0c\u8fd9\u6837\u53ef\u4ee5\u83b7\u5f97\u66f4\u7a33\u5b9a\u7684\u5b89\u5168\u66f4\u65b0\u548c\u9519\u8bef\u4fee\u590d\u3002<\/p>\n<p><strong>\u5728\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4e8b\u9879\uff1f<\/strong><br \/>\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python\u65f6\uff0c\u786e\u4fdd\u5df2\u5378\u8f7d\u7cfb\u7edf\u4e2d\u73b0\u6709\u7684\u76f8\u540c\u7248\u672c\uff0c\u4ee5\u907f\u514d\u51b2\u7a81\u3002\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982pyenv\u3001Anaconda\u7b49\uff09\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002\u786e\u8ba4\u5b89\u88c5\u8def\u5f84\u6ca1\u6709\u88ab\u5176\u4ed6\u8f6f\u4ef6\u5360\u7528\uff0c\u786e\u4fdd\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6b63\u786e\uff0c\u4ee5\u4fbf\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u987a\u5229\u8c03\u7528\u8be5\u7248\u672c\u7684Python\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6240\u9700\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\u5e76\u8fdb\u884c\u5b89\u88c5\u3002\u5728Mac\u548cLinux\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982Homebrew\u6216apt-get\uff09\u8fdb\u884c\u5b89\u88c5\uff0c\u5177\u4f53\u547d\u4ee4\u6839\u636e\u6240\u9700\u7248\u672c\u7684\u4e0d\u540c\u800c\u6709\u6240\u53d8\u5316\u3002\u786e\u4fdd\u9075\u5faa\u6bcf\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u6b65\u9aa4\u548c\u63a8\u8350\u7684\u914d\u7f6e\uff0c\u4ee5\u786e\u4fddPython\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684Python\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u3001\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002 \u5176\u4e2d\uff0c\u4f7f\u7528\u7248\u672c [&hellip;]","protected":false},"author":3,"featured_media":964037,"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\/964034"}],"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=964034"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/964034\/revisions"}],"predecessor-version":[{"id":964038,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/964034\/revisions\/964038"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/964037"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=964034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=964034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=964034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}