{"id":1160484,"date":"2025-01-13T19:05:24","date_gmt":"2025-01-13T11:05:24","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1160484.html"},"modified":"2025-01-13T19:05:27","modified_gmt":"2025-01-13T11:05:27","slug":"mac%e7%9a%84vscode%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aepython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1160484.html","title":{"rendered":"mac\u7684vscode\u5982\u4f55\u914d\u7f6epython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25201938\/a3d10caf-08ea-403f-bef1-5fc3476d43c0.webp\" alt=\"mac\u7684vscode\u5982\u4f55\u914d\u7f6epython\" \/><\/p>\n<p><p> \u5728macOS\u4e0a\u914d\u7f6eVS Code\u4ee5\u4f7f\u7528Python\u975e\u5e38\u7b80\u5355\u3002<strong>\u4e3b\u8981\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u5b89\u88c5VS Code\u3001\u5b89\u88c5Python\u6269\u5c55\u3001\u914d\u7f6ePython\u73af\u5883<\/strong>\u3002\u5176\u4e2d\uff0c\u8be6\u7ec6\u63cf\u8ff0\u4e00\u4e0b\u5982\u4f55\u5b89\u88c5Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\uff08Terminal\uff09\u3002<\/li>\n<li>\u4f7f\u7528Homebrew\uff08\u5982\u679c\u6ca1\u6709\u5b89\u88c5Homebrew\uff0c\u53ef\u4ee5\u5148\u5b89\u88c5\uff09\u6765\u5b89\u88c5Python\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-shell\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1Python\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\uff1a\n<pre><code class=\"language-shell\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e00\u3001\u5b89\u88c5VS Code<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u5728macOS\u4e0a\u914d\u7f6eVS Code\u4ee5\u4f7f\u7528Python\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5VS Code\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u4e0b\u8f7dVS Code\uff1a<\/strong>\n<ul>\n<li>\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>\u70b9\u51fb\u201cDownload\u201d\u6309\u94ae\uff0c\u9009\u62e9macOS\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5b89\u88c5VS Code\uff1a<\/strong>\n<ul>\n<li>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u4e0b\u8f7d\u6587\u4ef6\u5939\uff0c\u5c06Visual Studio Code\u5e94\u7528\u7a0b\u5e8f\u62d6\u52a8\u5230\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\u4e2d\u3002<\/li>\n<li>\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7Launchpad\u6216Spotlight\u641c\u7d22Visual Studio Code\u6765\u6253\u5f00\u5b83\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u5b89\u88c5Python\u6269\u5c55<\/h3>\n<\/p>\n<ol>\n<li><strong>\u542f\u52a8VS Code\uff1a<\/strong>\n<ul>\n<li>\u53cc\u51fbVisual Studio Code\u56fe\u6807\u4ee5\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6253\u5f00\u6269\u5c55\u7ba1\u7406\u5668\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u7684\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u70b9\u51fb\u201c\u6269\u5c55\u201d\u56fe\u6807\uff0c\u6216\u8005\u4f7f\u7528\u5feb\u6377\u952e<code>Cmd+Shift+X<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u641c\u7d22\u548c\u5b89\u88c5Python\u6269\u5c55\uff1a<\/strong>\n<ul>\n<li>\u5728\u641c\u7d22\u680f\u4e2d\u8f93\u5165\u201cPython\u201d\uff0c\u9009\u62e9\u7531Microsoft\u63d0\u4f9b\u7684Python\u6269\u5c55\uff0c\u7136\u540e\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0cPython\u6269\u5c55\u5c06\u63d0\u4f9b\u4ee3\u7801\u81ea\u52a8\u5b8c\u6210\u3001\u8c03\u8bd5\u3001linting\u7b49\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u914d\u7f6ePython\u73af\u5883<\/h3>\n<\/p>\n<ol>\n<li><strong>\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff1a<\/strong>\n<ul>\n<li>\u4f7f\u7528\u5feb\u6377\u952e<code>Cmd+Shift+P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u9009\u62e9Python\u89e3\u91ca\u5668\uff1a<\/strong>\n<ul>\n<li>\u5728\u547d\u4ee4\u9762\u677f\u4e2d\u8f93\u5165<code>Python: Select Interpreter<\/code>\uff0c\u7136\u540e\u9009\u62e9\u76f8\u5e94\u7684Python\u89e3\u91ca\u5668\uff08\u901a\u5e38\u662f<code>Python 3.x.x 64-bit<\/code>\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u521b\u5efa\u5e76\u6253\u5f00Python\u6587\u4ef6\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\uff08\u4f8b\u5982<code>example.py<\/code>\uff09\uff0c\u7136\u540e\u6253\u5f00\u5b83\u3002<\/li>\n<li>\u8f93\u5165\u4e00\u4e9bPython\u4ee3\u7801\uff0c\u4f8b\u5982\uff1a\n<pre><code class=\"language-python\">print(&quot;Hello, world!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd0\u884cPython\u4ee3\u7801\uff1a<\/strong>\n<ul>\n<li>\u5728Python\u6587\u4ef6\u4e2d\u53f3\u952e\u5355\u51fb\uff0c\u7136\u540e\u9009\u62e9\u201cRun Python File in Terminal\u201d\u3002<\/li>\n<li>\u4ee3\u7801\u5c06\u4f1a\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\uff0c\u5e76\u8f93\u51fa\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u5b89\u88c5\u5e76\u914d\u7f6e\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5\u865a\u62df\u73af\u5883\uff1a<\/strong>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5<code>virtualenv<\/code>\uff1a\n<pre><code class=\"language-shell\">pip3 install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/strong>\n<ul>\n<li>\u5bfc\u822a\u5230\u4f60\u60f3\u8981\u521b\u5efa\u865a\u62df\u73af\u5883\u7684\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-shell\">python3 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5176\u4e2d\uff0c<code>myenv<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-shell\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u6fc0\u6d3b\u540e\uff0c\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u524d\u4f1a\u51fa\u73b0\u865a\u62df\u73af\u5883\u540d\u79f0\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u914d\u7f6eVS Code\u4f7f\u7528\u865a\u62df\u73af\u5883\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\u6253\u5f00\u9879\u76ee\u76ee\u5f55\uff0c\u4f7f\u7528\u5feb\u6377\u952e<code>Cmd+Shift+P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\u3002<\/li>\n<li>\u8f93\u5165<code>Python: Select Interpreter<\/code>\uff0c\u7136\u540e\u9009\u62e9\u865a\u62df\u73af\u5883\u4e2d\u7684Python\u89e3\u91ca\u5668\uff08\u901a\u5e38\u4f4d\u4e8e<code>myenv\/bin\/python<\/code>\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u5b89\u88c5Python\u5e93<\/h3>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5\u5e38\u7528\u7684Python\u5e93\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684Python\u5e93\uff0c\u4f8b\u5982\uff1a\n<pre><code class=\"language-shell\">pip install numpy pandas matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5728VS Code\u4e2d\u4f7f\u7528\u5b89\u88c5\u7684\u5e93\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\u7f16\u5199Python\u4ee3\u7801\uff0c\u5e76\u5bfc\u5165\u4f60\u5b89\u88c5\u7684\u5e93\uff0c\u4f8b\u5982\uff1a\n<pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import pandas as pd<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u914d\u7f6eLinting\u548c\u683c\u5f0f\u5316\u5de5\u5177<\/h3>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5Linting\u5de5\u5177\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u5b89\u88c5<code>pylint<\/code>\uff1a\n<pre><code class=\"language-shell\">pip install pylint<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u914d\u7f6eLinting\u5de5\u5177\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\uff0c\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff08<code>Cmd+Shift+P<\/code>\uff09\uff0c\u8f93\u5165<code>Python: Select Linter<\/code>\uff0c\u7136\u540e\u9009\u62e9<code>pylint<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5b89\u88c5\u683c\u5f0f\u5316\u5de5\u5177\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u5b89\u88c5<code>autopep8<\/code>\u6216<code>black<\/code>\uff1a\n<pre><code class=\"language-shell\">pip install autopep8<\/p>\n<h2><strong>\u6216\u8005<\/strong><\/h2>\n<p>pip install black<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u914d\u7f6e\u683c\u5f0f\u5316\u5de5\u5177\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u7684\u8bbe\u7f6e\u4e2d\uff0c\u641c\u7d22<code>python formatting provider<\/code>\uff0c\u9009\u62e9<code>autopep8<\/code>\u6216<code>black<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u8c03\u8bd5Python\u4ee3\u7801<\/h3>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u8c03\u8bd5\u914d\u7f6e\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\uff0c\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u7684\u201c\u8fd0\u884c\u201d\u56fe\u6807\uff0c\u6216\u8005\u4f7f\u7528\u5feb\u6377\u952e<code>Cmd+Shift+D<\/code>\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u521b\u5efalaunch.json\u6587\u4ef6\u201d\u6309\u94ae\uff0c\u9009\u62e9\u201cPython\u201d\u3002<\/li>\n<li>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u9ed8\u8ba4\u7684\u8c03\u8bd5\u914d\u7f6e\u6587\u4ef6<code>launch.json<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6dfb\u52a0\u65ad\u70b9\uff1a<\/strong>\n<ul>\n<li>\u5728Python\u4ee3\u7801\u4e2d\u5355\u51fb\u884c\u53f7\u5de6\u4fa7\uff0c\u6dfb\u52a0\u65ad\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u542f\u52a8\u8c03\u8bd5\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u7684\u8c03\u8bd5\u9762\u677f\u4e2d\uff0c\u70b9\u51fb\u7eff\u8272\u7684\u201c\u542f\u52a8\u8c03\u8bd5\u201d\u6309\u94ae\u3002<\/li>\n<li>\u8c03\u8bd5\u5668\u5c06\u542f\u52a8\u5e76\u5728\u65ad\u70b9\u5904\u6682\u505c\uff0c\u5141\u8bb8\u4f60\u68c0\u67e5\u53d8\u91cf\u548c\u6267\u884c\u9010\u6b65\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u516b\u3001\u4f7f\u7528Jupyter Notebook<\/h3>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5Jupyter\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u5b89\u88c5Jupyter\uff1a\n<pre><code class=\"language-shell\">pip install jupyter<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6253\u5f00Jupyter Notebook\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\uff0c\u4f7f\u7528\u5feb\u6377\u952e<code>Cmd+Shift+P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u8f93\u5165<code>Python: Create New Blank Notebook<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd0\u884cJupyter Notebook\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\uff0c\u6253\u5f00\u4e00\u4e2a<code>.ipynb<\/code>\u6587\u4ef6\uff0c\u5e76\u8fd0\u884c\u5176\u4e2d\u7684\u4ee3\u7801\u5355\u5143\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e5d\u3001\u4f7f\u7528\u7248\u672c\u63a7\u5236<\/h3>\n<\/p>\n<ol>\n<li><strong>\u914d\u7f6eGit\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\uff0c\u5b89\u88c5Git\uff08\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff09\uff1a\n<pre><code class=\"language-shell\">brew install git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u914d\u7f6eGit\u7528\u6237\u4fe1\u606f\uff1a\n<pre><code class=\"language-shell\">git config --global user.name &quot;Your Name&quot;<\/p>\n<p>git config --global user.em<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l &quot;you@example.com&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5728VS Code\u4e2d\u4f7f\u7528Git\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u7684\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u70b9\u51fb\u201c\u6e90\u4ee3\u7801\u7ba1\u7406\u201d\u56fe\u6807\u3002<\/li>\n<li>\u521d\u59cb\u5316Git\u4ed3\u5e93\u5e76\u8fdb\u884c\u63d0\u4ea4\uff1a\n<pre><code class=\"language-shell\">git init<\/p>\n<p>git add .<\/p>\n<p>git commit -m &quot;Initial commit&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u3001\u4f7f\u7528Python\u6d4b\u8bd5\u6846\u67b6<\/h3>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5\u6d4b\u8bd5\u6846\u67b6\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u5b89\u88c5<code>pytest<\/code>\uff1a\n<pre><code class=\"language-shell\">pip install pytest<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7f16\u5199\u6d4b\u8bd5\u7528\u4f8b\uff1a<\/strong>\n<ul>\n<li>\u5728VS Code\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u6587\u4ef6\uff08\u4f8b\u5982<code>test_example.py<\/code>\uff09\uff0c\u5e76\u7f16\u5199\u6d4b\u8bd5\u7528\u4f8b\uff1a\n<pre><code class=\"language-python\">def test_addition():<\/p>\n<p>    assert 1 + 1 == 2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd0\u884c\u6d4b\u8bd5\u7528\u4f8b\uff1a<\/strong>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\uff0c\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\u5e76\u8fd0\u884c<code>pytest<\/code>\uff1a\n<pre><code class=\"language-shell\">pytest<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5728macOS\u4e0a\u914d\u7f6eVS Code\u4ee5\u4f7f\u7528Python\u3002\u8fd9\u4e9b\u6b65\u9aa4\u6db5\u76d6\u4e86\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u5b89\u88c5VS Code\u3001\u5b89\u88c5Python\u6269\u5c55\u3001\u914d\u7f6ePython\u73af\u5883\u3001\u5b89\u88c5\u5e76\u914d\u7f6e\u865a\u62df\u73af\u5883\u3001\u5b89\u88c5Python\u5e93\u3001\u914d\u7f6eLinting\u548c\u683c\u5f0f\u5316\u5de5\u5177\u3001\u8c03\u8bd5Python\u4ee3\u7801\u3001\u4f7f\u7528Jupyter Notebook\u3001\u4f7f\u7528\u7248\u672c\u63a7\u5236\u3001\u4ee5\u53ca\u4f7f\u7528Python\u6d4b\u8bd5\u6846\u67b6\u7b49\u65b9\u9762\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Mac\u4e0a\u5b89\u88c5Python\u548cVSCode\uff1f<\/strong><br \/>\u5728Mac\u4e0a\u5b89\u88c5Python\u53ef\u4ee5\u901a\u8fc7Homebrew\u6216\u76f4\u63a5\u4ecePython\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u5305\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u786e\u4fdd\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>python3 --version<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002\u81f3\u4e8eVSCode\uff0c\u53ef\u4ee5\u4ece\u5176\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u5305\uff0c\u5b8c\u6210\u540e\u6253\u5f00VSCode\u5e76\u5b89\u88c5Python\u6269\u5c55\u4ee5\u4fbf\u4e8e\u4ee3\u7801\u7f16\u5199\u548c\u8c03\u8bd5\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728VSCode\u4e2d\u8bbe\u7f6ePython\u89e3\u91ca\u5668\uff1f<\/strong><br \/>\u5728VSCode\u4e2d\u6253\u5f00\u4e00\u4e2aPython\u9879\u76ee\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0b<code>Command + Shift + P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u8f93\u5165\u5e76\u9009\u62e9\u201cPython: Select Interpreter\u201d\u3002\u8fd9\u5c06\u5217\u51fa\u7cfb\u7edf\u4e2d\u53ef\u7528\u7684Python\u89e3\u91ca\u5668\uff0c\u9009\u62e9\u4f60\u9700\u8981\u7684\u7248\u672c\u5373\u53ef\u3002\u786e\u4fdd\u9009\u4e2d\u7684\u89e3\u91ca\u5668\u4e0e\u9879\u76ee\u76f8\u5339\u914d\uff0c\u4ee5\u907f\u514d\u8fd0\u884c\u9519\u8bef\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728VSCode\u4e2d\u8fd0\u884cPython\u4ee3\u7801\uff1f<\/strong><br \/>\u5728VSCode\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u4e00\u4e2aPython\u6587\u4ef6\uff0c\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u201cRun Python File\u201d\u6309\u94ae\u6765\u8fd0\u884c\u4ee3\u7801\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u96c6\u6210\u7ec8\u7aef\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165<code>python3 &lt;filename&gt;.py<\/code>\u547d\u4ee4\u6765\u6267\u884cPython\u811a\u672c\u3002\u786e\u4fdd\u5728\u8fd0\u884c\u4e4b\u524d\uff0c\u5df2\u5b89\u88c5\u6240\u9700\u7684\u5e93\u548c\u4f9d\u8d56\uff0c\u4ee5\u4fdd\u8bc1\u4ee3\u7801\u80fd\u591f\u6b63\u5e38\u6267\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728macOS\u4e0a\u914d\u7f6eVS Code\u4ee5\u4f7f\u7528Python\u975e\u5e38\u7b80\u5355\u3002\u4e3b\u8981\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u5b89\u88c5VS Co [&hellip;]","protected":false},"author":3,"featured_media":1160494,"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\/1160484"}],"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=1160484"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160484\/revisions"}],"predecessor-version":[{"id":1160502,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1160484\/revisions\/1160502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1160494"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1160484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1160484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1160484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}