{"id":1151157,"date":"2025-01-13T17:10:11","date_gmt":"2025-01-13T09:10:11","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1151157.html"},"modified":"2025-01-13T17:10:13","modified_gmt":"2025-01-13T09:10:13","slug":"mac%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80python%e8%bd%af%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1151157.html","title":{"rendered":"mac\u5982\u4f55\u6253\u5f00python\u8f6f\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25181502\/33998e4c-4300-4a5f-af70-87b284e4f1b3.webp\" alt=\"mac\u5982\u4f55\u6253\u5f00python\u8f6f\u4ef6\" \/><\/p>\n<p><p> <strong>\u8981\u5728Mac\u4e0a\u6253\u5f00Python\u8f6f\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528\u7ec8\u7aef\u3001\u5b89\u88c5\u56fe\u5f62\u5316\u7684Python IDE\u3001\u901a\u8fc7Anaconda\u5b89\u88c5Python\u73af\u5883\u7b49\u3002\u5177\u4f53\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528\u7ec8\u7aef\u6253\u5f00Python\u3001\u4f7f\u7528Python IDE\u6253\u5f00Python\u3001\u901a\u8fc7Anaconda\u6253\u5f00Python\u3002<\/strong><\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u7ec8\u7aef\u6253\u5f00Python<\/h3>\n<\/p>\n<p><p>\u5728Mac\u4e0a\uff0c\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u4e4b\u4e00\u5c31\u662f\u901a\u8fc7\u7ec8\u7aef\u8fd0\u884cPython\u3002Python\u901a\u5e38\u9884\u88c5\u5728macOS\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u6253\u5f00\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00\u7ec8\u7aef\u5e94\u7528\u7a0b\u5e8f<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f60\u53ef\u4ee5\u901a\u8fc7\u6309<code>Command + \u7a7a\u683c<\/code>\u8c03\u51faSpotlight\u641c\u7d22\uff0c\u8f93\u5165\u201c\u7ec8\u7aef\u201d\u5e76\u6309\u56de\u8f66\u952e\uff0c\u6216\u8005\u4ece\u201c\u5e94\u7528\u7a0b\u5e8f\u201d -&gt; \u201c\u5b9e\u7528\u5de5\u5177\u201d -&gt; \u201c\u7ec8\u7aef\u201d\u6765\u6253\u5f00\u7ec8\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5Python<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u7cfb\u7edf\u4e2d\u662f\u5426\u5df2\u5b89\u88c5Python\uff1a\n<pre><code class=\"language-sh\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u6216\u8005<\/p>\n<pre><code class=\"language-sh\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u5982\u679c\u4f60\u770b\u5230Python\u7248\u672c\u53f7\u8f93\u51fa\uff0c\u8bf4\u660ePython\u5df2\u5b89\u88c5\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5b89\u88c5\u3002<\/li>\n<\/p>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u89e3\u91ca\u5668<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u5e76\u6309\u56de\u8f66\u952e\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff1a\n<pre><code class=\"language-sh\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u6216\u8005<\/p>\n<pre><code class=\"language-sh\">python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u4f60\u5c06\u770b\u5230\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u7684\u63d0\u793a\u7b26\uff0c\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u73af\u5883\uff1a\n<pre><code class=\"language-python\">Python 3.X.X (default, ...) <\/p>\n<p>[GCC ...] on darwin<\/p>\n<p>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<\/p>\n<p>&gt;&gt;&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884cPython\u89e3\u91ca\u5668\u975e\u5e38\u9002\u5408\u8fdb\u884c\u7b80\u5355\u7684\u6d4b\u8bd5\u548c\u811a\u672c\u8fd0\u884c\uff0c\u4f46\u5982\u679c\u4f60\u5e0c\u671b\u6709\u66f4\u597d\u7684\u5f00\u53d1\u4f53\u9a8c\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u56fe\u5f62\u5316\u7684IDE\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Python IDE\u6253\u5f00Python<\/h3>\n<\/p>\n<p><p>Python IDE\uff08\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff09\u63d0\u4f9b\u4e86\u66f4\u4e30\u5bcc\u7684\u5f00\u53d1\u5de5\u5177\u548c\u529f\u80fd\uff0c\u9002\u5408\u590d\u6742\u9879\u76ee\u7684\u5f00\u53d1\u3002\u4ee5\u4e0b\u662f\u51e0\u79cd\u5e38\u7528\u7684Python IDE\u53ca\u5176\u5b89\u88c5\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>PyCharm<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b89\u88c5PyCharm<\/strong>\uff1a\n<ol>\n<li>\u6253\u5f00\u7f51\u9875\u6d4f\u89c8\u5668\uff0c\u8bbf\u95eePyCharm\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.jetbrains.com\/pycharm\/%EF%BC%89%E3%80%82\">https:\/\/www.jetbr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns.com\/pycharm\/\uff09\u3002<\/a><\/li>\n<li>\u4e0b\u8f7d\u9002\u7528\u4e8emacOS\u7684PyCharm\u5b89\u88c5\u5305\u3002<\/li>\n<li>\u6253\u5f00\u4e0b\u8f7d\u7684.dmg\u6587\u4ef6\uff0c\u5e76\u5c06PyCharm\u62d6\u52a8\u5230\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\u4e2d\u3002<\/li>\n<\/ol>\n<\/li>\n<li><strong>\u4f7f\u7528PyCharm<\/strong>\uff1a\n<ol>\n<li>\u6253\u5f00\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\uff0c\u627e\u5230\u5e76\u542f\u52a8PyCharm\u3002<\/li>\n<li>\u5728PyCharm\u4e2d\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u65b0\u7684Python\u9879\u76ee\u6216\u6253\u5f00\u73b0\u6709\u7684\u9879\u76ee\u3002<\/li>\n<li>\u5728\u9879\u76ee\u4e2d\uff0c\u4f60\u53ef\u4ee5\u7f16\u5199\u3001\u8fd0\u884c\u548c\u8c03\u8bd5Python\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Visual Studio Code (VS Code)<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b89\u88c5VS Code<\/strong>\uff1a\n<ol>\n<li>\u6253\u5f00\u7f51\u9875\u6d4f\u89c8\u5668\uff0c\u8bbf\u95eeVS Code\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/code.visualstudio.com\/%EF%BC%89%E3%80%82\">https:\/\/code.visualstudio.com\/\uff09\u3002<\/a><\/li>\n<li>\u4e0b\u8f7d\u9002\u7528\u4e8emacOS\u7684VS Code\u5b89\u88c5\u5305\u3002<\/li>\n<li>\u6253\u5f00\u4e0b\u8f7d\u7684.dmg\u6587\u4ef6\uff0c\u5e76\u5c06VS Code\u62d6\u52a8\u5230\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\u4e2d\u3002<\/li>\n<\/ol>\n<\/li>\n<li><strong>\u5b89\u88c5Python\u6269\u5c55<\/strong>\uff1a\n<ol>\n<li>\u542f\u52a8VS Code\u3002<\/li>\n<li>\u5728VS Code\u7684\u6269\u5c55\u5e02\u573a\u4e2d\uff0c\u641c\u7d22\u5e76\u5b89\u88c5Python\u6269\u5c55\uff08\u7531Microsoft\u63d0\u4f9b\uff09\u3002<\/li>\n<\/ol>\n<\/li>\n<li><strong>\u4f7f\u7528VS Code<\/strong>\uff1a\n<ol>\n<li>\u6253\u5f00\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\uff0c\u627e\u5230\u5e76\u542f\u52a8VS Code\u3002<\/li>\n<li>\u5728VS Code\u4e2d\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u65b0\u7684Python\u6587\u4ef6\u6216\u6253\u5f00\u73b0\u6709\u7684Python\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528VS Code\u7684\u96c6\u6210\u7ec8\u7aef\u548c\u8c03\u8bd5\u5de5\u5177\u6765\u8fd0\u884c\u548c\u8c03\u8bd5Python\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Jupyter Notebook<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b89\u88c5Jupyter Notebook<\/strong>\uff1a\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Jupyter Notebook\uff1a\n<pre><code class=\"language-sh\">pip install jupyter<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li><strong>\u542f\u52a8Jupyter Notebook<\/strong>\uff1a\n<ol>\n<li>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Jupyter Notebook\uff1a\n<pre><code class=\"language-sh\">jupyter notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>Jupyter Notebook\u5c06\u5728\u4f60\u7684\u9ed8\u8ba4\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00\uff0c\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u521b\u5efa\u548c\u7f16\u8f91Python\u7b14\u8bb0\u672c\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u901a\u8fc7Anaconda\u6253\u5f00Python<\/h3>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Python\u53d1\u884c\u7248\uff0c\u5305\u542b\u4e86\u8bb8\u591a\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684\u5305\u3002\u5b83\u8fd8\u9644\u5e26\u4e86\u4e00\u4e2a\u56fe\u5f62\u5316\u7684\u5305\u7ba1\u7406\u5668\u548c\u73af\u5883\u7ba1\u7406\u5668\uff0c\u65b9\u4fbf\u7ba1\u7406Python\u73af\u5883\u548c\u5305\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Anaconda<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7f51\u9875\u6d4f\u89c8\u5668\uff0c\u8bbf\u95eeAnaconda\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.anaconda.com\/%EF%BC%89%E3%80%82\">https:\/\/www.anaconda.com\/\uff09\u3002<\/a><\/li>\n<li>\u4e0b\u8f7d\u9002\u7528\u4e8emacOS\u7684Anaconda\u5b89\u88c5\u5305\u3002<\/li>\n<li>\u6253\u5f00\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff0c\u5e76\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Anaconda Navigator<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\uff0c\u627e\u5230\u5e76\u542f\u52a8Anaconda Navigator\u3002<\/li>\n<li>\u5728Anaconda Navigator\u4e2d\uff0c\u4f60\u53ef\u4ee5\u7ba1\u7406\u4e0d\u540c\u7684Python\u73af\u5883\uff0c\u5b89\u88c5\u548c\u66f4\u65b0\u5305\uff0c\u5e76\u542f\u52a8\u5404\u79cd\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08\u5982Jupyter Notebook\u3001Spyder\u7b49\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528conda\u547d\u4ee4<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528<code>conda<\/code>\u547d\u4ee4\u6765\u7ba1\u7406\u73af\u5883\u548c\u5305\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u73af\u5883\uff1a\n<pre><code class=\"language-sh\">conda create --name myenv python=3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u6fc0\u6d3b\u73af\u5883\uff1a\n<pre><code class=\"language-sh\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728\u6fc0\u6d3b\u7684\u73af\u5883\u4e2d\u8fd0\u884cPython\uff1a\n<pre><code class=\"language-sh\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5728Mac\u4e0a\u8f7b\u677e\u6253\u5f00\u548c\u4f7f\u7528Python\u8f6f\u4ef6\u3002\u9009\u62e9\u9002\u5408\u4f60\u9700\u6c42\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u4f60\u7684\u5f00\u53d1\u6548\u7387\u548c\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Mac\u4e0a\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728Mac\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u547d\u4ee4<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u68c0\u67e5Python\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5982\u679c\u5df2\u7ecf\u5b89\u88c5\uff0c\u7cfb\u7edf\u5c06\u663e\u793aPython\u7684\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5b89\u88c5\u5305\u3002<\/p>\n<p><strong>\u5728Mac\u4e0a\u5982\u4f55\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u7684Mac\u5c1a\u672a\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u524d\u5f80Python\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u9002\u5408\u60a8\u7cfb\u7edf\u7684\u6700\u65b0\u7248\u672c\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u5b89\u88c5\u5305\u5e76\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528Homebrew\u7b49\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u901a\u8fc7\u547d\u4ee4<code>brew install python<\/code>\u6765\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Mac\u4e0a\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u8981\u5728Mac\u4e0a\u8fd0\u884cPython\u811a\u672c\uff0c\u60a8\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\u3002\u7136\u540e\u8f93\u5165\u547d\u4ee4<code>python script_name.py<\/code>\uff08\u5982\u679c\u4f7f\u7528Python 3\uff0c\u5219\u4f7f\u7528<code>python3 script_name.py<\/code>\uff09\u3002\u786e\u4fdd\u5c06<code>script_name.py<\/code>\u66ff\u6362\u4e3a\u60a8\u7684\u811a\u672c\u6587\u4ef6\u540d\u3002\u8fd0\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u811a\u672c\u7684\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Mac\u4e0a\u6253\u5f00Python\u8f6f\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528\u7ec8\u7aef\u3001\u5b89\u88c5\u56fe\u5f62\u5316\u7684Python IDE\u3001\u901a\u8fc7Ana [&hellip;]","protected":false},"author":3,"featured_media":1151162,"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\/1151157"}],"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=1151157"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1151157\/revisions"}],"predecessor-version":[{"id":1151166,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1151157\/revisions\/1151166"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1151162"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1151157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1151157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1151157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}