{"id":1088801,"date":"2025-01-08T13:47:38","date_gmt":"2025-01-08T05:47:38","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1088801.html"},"modified":"2025-01-08T13:47:40","modified_gmt":"2025-01-08T05:47:40","slug":"%e5%a6%82%e4%bd%95%e7%9c%8bpython%e7%9a%84%e5%ae%89%e8%a3%85%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1088801.html","title":{"rendered":"\u5982\u4f55\u770bpython\u7684\u5b89\u88c5\u73af\u5883\u53d8\u91cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24201102\/d589f23c-d06e-477b-90d7-c3830b6623c7.webp\" alt=\"\u5982\u4f55\u770bpython\u7684\u5b89\u88c5\u73af\u5883\u53d8\u91cf\" \/><\/p>\n<p><p> <strong>\u8981\u67e5\u770bPython\u7684\u5b89\u88c5\u73af\u5883\u53d8\u91cf\uff0c\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5PATH\u53d8\u91cf\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u3001\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u7b49\u65b9\u6cd5\u6765\u5b9e\u73b0<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u6765\u67e5\u770b\u548c\u4fee\u6539\u73af\u5883\u53d8\u91cf\u662f\u6700\u65b9\u4fbf\u548c\u76f4\u63a5\u7684\u65b9\u6cd5\u3002<strong>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u76f8\u5173\u547d\u4ee4\uff0c\u53ef\u4ee5\u5feb\u901f\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\u548c\u73af\u5883\u53d8\u91cf\u7684\u914d\u7f6e<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u4e0d\u540c\u65b9\u6cd5\u67e5\u770b\u548c\u7ba1\u7406Python\u7684\u5b89\u88c5\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770bPython\u5b89\u88c5\u8def\u5f84<\/h2>\n<\/p>\n<p><h3>1. Windows\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff08cmd\uff09\u6765\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\uff1a\n<pre><code class=\"language-cmd\">where python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u8be5\u547d\u4ee4\u4f1a\u8fd4\u56dePython\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002\u5982\u679c\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u547d\u4ee4\u4f1a\u5217\u51fa\u6240\u6709\u7248\u672c\u7684\u8def\u5f84\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h3>2. macOS\u548cLinux\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\uff08Terminal\uff09\u6765\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\uff1a\n<pre><code class=\"language-bash\">which python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u8be5\u547d\u4ee4\u4f1a\u8fd4\u56dePython\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002\u4e0eWindows\u7cfb\u7edf\u7c7b\u4f3c\uff0c\u5982\u679c\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u547d\u4ee4\u4f1a\u5217\u51fa\u9ed8\u8ba4\u7248\u672c\u7684\u8def\u5f84\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h2>\u4e8c\u3001\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e<\/h2>\n<\/p>\n<p><h3>1. Windows\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u5c5e\u6027\u6765\u67e5\u770b\u548c\u7ba1\u7406\u73af\u5883\u53d8\u91cf\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\u56fe\u6807\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u53ef\u4ee5\u67e5\u770b\u548c\u7f16\u8f91\u7528\u6237\u53d8\u91cf\u548c\u7cfb\u7edf\u53d8\u91cf\u3002\u67e5\u627e\u540d\u4e3a<code>PATH<\/code>\u7684\u53d8\u91cf\uff0c\u786e\u4fdd\u5176\u4e2d\u5305\u542bPython\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u5982<code>C:\\Python39<\/code>\u6216\u5176\u4ed6\u7248\u672c\u7684\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><h3>2. macOS\u548cLinux\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u548c\u7f16\u8f91shell\u914d\u7f6e\u6587\u4ef6\u6765\u7ba1\u7406\u73af\u5883\u53d8\u91cf\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00shell\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982<code>~\/.bashrc<\/code>\u3001<code>~\/.bash_profile<\/code>\u6216<code>~\/.zshrc<\/code>\uff0c\u5177\u4f53\u6587\u4ef6\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684shell\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>nano<\/code>\u7f16\u8f91\u5668\u6253\u5f00<code>~\/.bashrc<\/code>\u6587\u4ef6\uff1a\n<pre><code class=\"language-bash\">nano ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u67e5\u627e\u5305\u542b<code>PATH<\/code>\u53d8\u91cf\u7684\u884c\uff0c\u786e\u4fdd\u5176\u4e2d\u5305\u542bPython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u6dfb\u52a0Python\u8def\u5f84\uff1a\n<pre><code class=\"language-bash\">export PATH=&quot;\/path\/to\/python:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f7f\u66f4\u6539\u751f\u6548\uff1a\n<pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e09\u3001\u4f7f\u7528Python\u547d\u4ee4\u67e5\u770b\u5b89\u88c5\u4fe1\u606f<\/h2>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528Python\u81ea\u5e26\u7684\u547d\u4ee4\u6765\u67e5\u770b\u5b89\u88c5\u4fe1\u606f\u548c\u73af\u5883\u53d8\u91cf\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff1a\n<pre><code class=\"language-bash\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\u548c\u73af\u5883\u53d8\u91cf\uff1a\n<pre><code class=\"language-python\">import sys<\/p>\n<p>print(sys.executable)<\/p>\n<p>print(sys.path)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><code>sys.executable<\/code>\u8fd4\u56dePython\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\uff0c<code>sys.path<\/code>\u8fd4\u56dePython\u641c\u7d22\u6a21\u5757\u7684\u8def\u5f84\u5217\u8868\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h2>\u56db\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h2>\n<\/p>\n<p><p>\u8bb8\u591a\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u63d0\u4f9b\u4e86\u67e5\u770b\u548c\u7ba1\u7406Python\u73af\u5883\u53d8\u91cf\u7684\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528IDE\u7684\u5177\u4f53\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<p><h3>1. PyCharm<\/h3>\n<\/p>\n<p><p>\u5728PyCharm\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u6765\u67e5\u770b\u548c\u7ba1\u7406Python\u73af\u5883\u53d8\u91cf\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00PyCharm\uff0c\u8fdb\u5165\u9879\u76ee\u3002<\/li>\n<li>\u9009\u62e9\u201cFile\u201d\u83dc\u5355\uff0c\u70b9\u51fb\u201cSettings\u201d\u3002<\/li>\n<li>\u5728\u8bbe\u7f6e\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u201cProject: [project name]\u201d\u4e0b\u7684\u201cPython Interpreter\u201d\u3002<\/li>\n<li>\u5728\u53f3\u4fa7\uff0c\u53ef\u4ee5\u67e5\u770b\u548c\u7ba1\u7406Python\u89e3\u91ca\u5668\u548c\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<\/ol>\n<p><h3>2. Visual Studio Code<\/h3>\n<\/p>\n<p><p>\u5728Visual Studio Code\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u6765\u67e5\u770b\u548c\u7ba1\u7406Python\u73af\u5883\u53d8\u91cf\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00Visual Studio Code\uff0c\u8fdb\u5165\u9879\u76ee\u3002<\/li>\n<li>\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff08\u5feb\u6377\u952e<code>Ctrl+Shift+P<\/code>\u6216<code>Cmd+Shift+P<\/code>\uff09\u3002<\/li>\n<li>\u8f93\u5165\u5e76\u9009\u62e9\u201cPython: Select Interpreter\u201d\u547d\u4ee4\u3002<\/li>\n<li>\u5728\u5217\u8868\u4e2d\u9009\u62e9\u6240\u9700\u7684Python\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u67e5\u770b\u5176\u5b89\u88c5\u8def\u5f84\u548c\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<\/ol>\n<p><h2>\u4e94\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><p>\u5728Python\u9879\u76ee\u4e2d\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\uff08virtual environment\uff09\u53ef\u4ee5\u9694\u79bb\u9879\u76ee\u4f9d\u8d56\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u4ee5\u4e0b\u662f\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\u7684\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><h3>1. \u521b\u5efa\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u53ef\u4ee5\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u8be5\u547d\u4ee4\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h3>2. \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u53ef\u4ee5\u4f7f\u5176\u6210\u4e3a\u5f53\u524d\u547d\u4ee4\u884c\u4f1a\u8bdd\u7684Python\u89e3\u91ca\u5668\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><h4>Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-cmd\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>macOS\u548cLinux\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3. \u67e5\u770b\u865a\u62df\u73af\u5883\u4fe1\u606f<\/h3>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u865a\u62df\u73af\u5883\u7684\u5b89\u88c5\u8def\u5f84\u548c\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">which python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>print(sys.executable)<\/p>\n<p>print(sys.path)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4. \u9000\u51fa\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u516d\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u67e5\u770b\u548c\u7ba1\u7406Python\u7684\u5b89\u88c5\u73af\u5883\u53d8\u91cf\u3002<strong>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u3001\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u3001\u4f7f\u7528Python\u547d\u4ee4\u67e5\u770b\u5b89\u88c5\u4fe1\u606f\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7b49\u65b9\u6cd5\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u597d\u5730\u7ba1\u7406\u548c\u914d\u7f6ePython\u73af\u5883<\/strong>\u3002\u5408\u7406\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u6709\u52a9\u4e8e\u907f\u514d\u4f9d\u8d56\u51b2\u7a81\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u786e\u4fdd\u9879\u76ee\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u5e0c\u671b\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u60a8\u80fd\u591f\u638c\u63e1\u67e5\u770b\u548c\u7ba1\u7406Python\u5b89\u88c5\u73af\u5883\u53d8\u91cf\u7684\u6280\u5de7\uff0c\u4e3aPython\u5f00\u53d1\u5de5\u4f5c\u5e26\u6765\u4fbf\u5229\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5Python\u662f\u5426\u6b63\u786e\u5b89\u88c5\u5728\u7cfb\u7edf\u4e2d\uff1f<\/strong><br \/>\u8981\u786e\u8ba4Python\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u3002\u5982\u679c\u7cfb\u7edf\u8fd4\u56de\u4e86Python\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002\u5982\u679c\u63d0\u793a\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\uff0c\u5219\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u5b89\u88c5\u6216\u68c0\u67e5\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Windows\u4e2d\u67e5\u770bPython\u7684\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u8fdb\u5165\u201c\u73af\u5883\u53d8\u91cf\u201d\u754c\u9762\u3002\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u5bfb\u627e\u540d\u4e3a\u201cPath\u201d\u7684\u53d8\u91cf\uff0c\u67e5\u770b\u662f\u5426\u5305\u542bPython\u7684\u5b89\u88c5\u8def\u5f84\uff08\u901a\u5e38\u662f\u7c7b\u4f3c\u4e8e<code>C:\\Python39<\/code>\u6216<code>C:\\Users\\\u7528\u6237\u540d\\AppData\\Local\\Programs\\Python\\Python39<\/code>\u7684\u8def\u5f84\uff09\u3002<\/p>\n<p><strong>\u5728Linux\u6216Mac\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u67e5\u770bPython\u7684\u73af\u5883\u53d8\u91cf\uff1f<\/strong><br \/>\u5728Linux\u6216Mac\u4e2d\uff0c\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165<code>echo $PATH<\/code>\u547d\u4ee4\u3002\u8fd9\u5c06\u663e\u793a\u5f53\u524d\u7684\u73af\u5883\u53d8\u91cf\u8def\u5f84\u5217\u8868\u3002\u67e5\u627e\u8f93\u51fa\u4e2d\u662f\u5426\u5305\u542bPython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528<code>which python<\/code>\u6216<code>which python3<\/code>\u547d\u4ee4\uff0c\u786e\u8ba4Python\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f4d\u7f6e\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u9a8c\u8bc1\u73af\u5883\u8bbe\u7f6e\u662f\u5426\u6b63\u786e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u67e5\u770bPython\u7684\u5b89\u88c5\u73af\u5883\u53d8\u91cf\uff0c\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5PATH\u53d8\u91cf\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u3001\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u7b49\u65b9\u6cd5\u6765\u5b9e\u73b0\u3002 [&hellip;]","protected":false},"author":3,"featured_media":1088810,"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\/1088801"}],"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=1088801"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1088801\/revisions"}],"predecessor-version":[{"id":1088813,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1088801\/revisions\/1088813"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1088810"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1088801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1088801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1088801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}