{"id":972723,"date":"2024-12-27T05:51:01","date_gmt":"2024-12-26T21:51:01","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/972723.html"},"modified":"2024-12-27T05:51:03","modified_gmt":"2024-12-26T21:51:03","slug":"mac%e5%a6%82%e4%bd%95%e4%b8%8b%e8%bd%bdpython%e8%bd%af%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/972723.html","title":{"rendered":"mac\u5982\u4f55\u4e0b\u8f7dpython\u8f6f\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24195243\/1f7c0c3e-c132-4f6d-8afd-6e2c9dd1540d.webp\" alt=\"mac\u5982\u4f55\u4e0b\u8f7dpython\u8f6f\u4ef6\" \/><\/p>\n<p><p> <strong>\u5728macOS\u4e0a\u4e0b\u8f7dPython\u8f6f\u4ef6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u6765\u5b8c\u6210\uff1a\u4f7f\u7528Homebrew\u5305\u7ba1\u7406\u5668\u3001\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u3001\u4f7f\u7528Anaconda\u5206\u53d1\u7248\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<\/p>\n<p><p><strong>1\u3001\u4f7f\u7528Homebrew\u5305\u7ba1\u7406\u5668<\/strong><\/p>\n<\/p>\n<p><p>Homebrew\u662fmacOS\u4e0a\u7684\u4e00\u4e2a\u6d41\u884c\u7684\u5305\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\u548c\u7ba1\u7406\u8f6f\u4ef6\u5305\u3002\u4f7f\u7528Homebrew\u5b89\u88c5Python\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684Mac\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Homebrew\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0Homebrew\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528Homebrew\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1Python\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\uff0c\u4f60\u7684Mac\u4e0a\u5c31\u5b89\u88c5\u4e86\u6700\u65b0\u7248\u672c\u7684Python\u3002\u4f7f\u7528Homebrew\u5b89\u88c5\u7684\u4e00\u4e2a\u597d\u5904\u662f\u5b83\u4f1a\u81ea\u52a8\u7ba1\u7406\u4f9d\u8d56\u9879\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u547d\u4ee4\u6765\u66f4\u65b0Python\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p><strong>2\u3001\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5e0c\u671b\u624b\u52a8\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u3002\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff1a<a href=\"https:\/\/www.python.org\">https:\/\/www.python.org<\/a>\u3002<\/p>\n<\/p>\n<p><p>\u5728\u9996\u9875\u4e2d\uff0c\u70b9\u51fb\u201cDownloads\u201d\u9009\u9879\u5361\uff0c\u7f51\u7ad9\u4f1a\u81ea\u52a8\u68c0\u6d4b\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u5e76\u63a8\u8350\u9002\u5408\u7684Python\u7248\u672c\u3002\u70b9\u51fb\u201cDownload Python X.X.X\u201d\u6309\u94ae\uff08X.X.X\u4e3a\u6700\u65b0\u7684\u7248\u672c\u53f7\uff09\u3002<\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff0c\u6309\u7167\u5b89\u88c5\u7a0b\u5e8f\u7684\u6307\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u70b9\u51fb\u201c\u7ee7\u7eed\u201d\u6309\u94ae\u5e76\u540c\u610f\u8bb8\u53ef\u534f\u8bae\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>3\u3001\u4f7f\u7528Anaconda\u5206\u53d1\u7248<\/strong><\/p>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u79cd\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684Python\u53d1\u884c\u7248\uff0c\u5305\u542b\u4e86\u5927\u91cf\u79d1\u5b66\u5305\u548c\u5de5\u5177\uff0c\u9002\u5408\u9700\u8981\u591a\u4e2aPython\u7248\u672c\u6216\u79d1\u5b66\u8ba1\u7b97\u73af\u5883\u7684\u7528\u6237\u3002\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><p>\u8bbf\u95eeAnaconda\u5b98\u65b9\u7f51\u7ad9\uff1a<a href=\"https:\/\/www.anaconda.com\">https:\/\/www.anaconda.com<\/a>\u3002<\/p>\n<\/p>\n<p><p>\u70b9\u51fb\u201cDownload\u201d\u9009\u9879\u5361\uff0c\u9009\u62e9\u9002\u5408macOS\u7684Anaconda\u7248\u672c\u4e0b\u8f7d\u3002<\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u5b89\u88c5\u7a0b\u5e8f\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u53ef\u80fd\u4f1a\u8be2\u95ee\u662f\u5426\u5c06Anaconda\u6dfb\u52a0\u5230\u7cfb\u7edf\u8def\u5f84\u4e2d\uff0c\u5efa\u8bae\u9009\u62e9\u6dfb\u52a0\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7Anaconda\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u548c\u865a\u62df\u73af\u5883\uff0c\u662f\u8fdb\u884c\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684\u7406\u60f3\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><p><strong>\u603b\u7ed3<\/strong><\/p>\n<\/p>\n<p><p>\u5728macOS\u4e0a\u5b89\u88c5Python\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u4f7f\u7528Homebrew\u53ef\u4ee5\u7b80\u5316\u5b89\u88c5\u548c\u66f4\u65b0\u8fc7\u7a0b\u3001\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408\u9700\u8981\u624b\u52a8\u63a7\u5236\u5b89\u88c5\u7684\u7528\u6237\u3001\u4f7f\u7528Anaconda\u5219\u9002\u5408\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u3002\u6839\u636e\u4e2a\u4eba\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u5e76\u786e\u4fdd\u5728\u5b89\u88c5\u540e\u9a8c\u8bc1Python\u662f\u5426\u6b63\u786e\u5b89\u88c5\u3002\u65e0\u8bba\u91c7\u7528\u54ea\u79cd\u65b9\u6cd5\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u90fd\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u548c\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Mac\u4e0a\u627e\u5230\u9002\u5408\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u5728Mac\u4e0a\u4e0b\u8f7dPython\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u975e\u5e38\u91cd\u8981\u3002\u4f60\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\uff0c\u5728\u4e0b\u8f7d\u9875\u9762\u4e2d\u53ef\u4ee5\u770b\u5230\u591a\u4e2a\u7248\u672c\u3002\u901a\u5e38\uff0c\u63a8\u8350\u4e0b\u8f7d\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u4ee5\u786e\u4fdd\u83b7\u5f97\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u6027\u3002\u5982\u679c\u4f60\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u4f8b\u59822.x\u7cfb\u5217\uff0c\u4e5f\u53ef\u4ee5\u5728\u540c\u4e00\u9875\u9762\u627e\u5230\u3002<\/p>\n<p><strong>\u4e0b\u8f7dPython\u540e\uff0c\u5982\u4f55\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165<code>python3 --version<\/code>\u6216\u8005<code>python --version<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u7cfb\u7edf\u5c06\u663e\u793a\u4f60\u6240\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002\u5982\u679c\u51fa\u73b0\u201ccommand not found\u201d\u8fd9\u6837\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u53ef\u80fd\u9700\u8981\u68c0\u67e5\u5b89\u88c5\u6b65\u9aa4\u6216\u8def\u5f84\u8bbe\u7f6e\u3002<\/p>\n<p><strong>\u5728Mac\u4e0a\u4f7f\u7528Python\u65f6\uff0c\u63a8\u8350\u54ea\u4e9b\u5f00\u53d1\u73af\u5883\u6216\u5de5\u5177\uff1f<\/strong><br \/>\u5728Mac\u4e0a\uff0c\u5e38\u7528\u7684Python\u5f00\u53d1\u73af\u5883\u5305\u62ecPyCharm\u3001Visual Studio Code\u548cJupyter Notebook\u3002PyCharm\u63d0\u4f9b\u5f3a\u5927\u7684IDE\u529f\u80fd\uff0c\u9002\u5408\u5927\u89c4\u6a21\u9879\u76ee\u5f00\u53d1\uff1b\u800cVisual Studio Code\u8f7b\u91cf\u7075\u6d3b\uff0c\u9002\u5408\u5feb\u901f\u5f00\u53d1\u548c\u8c03\u8bd5\uff1bJupyter Notebook\u5219\u65b9\u4fbf\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u3002\u8fd9\u4e9b\u5de5\u5177\u90fd\u53ef\u4ee5\u901a\u8fc7\u5404\u81ea\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\uff0c\u5e2e\u52a9\u63d0\u5347\u4f60\u7684Python\u7f16\u7a0b\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728macOS\u4e0a\u4e0b\u8f7dPython\u8f6f\u4ef6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u6765\u5b8c\u6210\uff1a\u4f7f\u7528Homebrew\u5305\u7ba1\u7406\u5668\u3001\u4ecePython [&hellip;]","protected":false},"author":3,"featured_media":972734,"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\/972723"}],"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=972723"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/972723\/revisions"}],"predecessor-version":[{"id":972735,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/972723\/revisions\/972735"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/972734"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=972723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=972723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=972723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}