{"id":1164231,"date":"2025-01-15T15:04:25","date_gmt":"2025-01-15T07:04:25","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1164231.html"},"modified":"2025-01-15T15:04:27","modified_gmt":"2025-01-15T07:04:27","slug":"%e5%a6%82%e4%bd%95%e6%89%bepython%e7%9a%84%e5%ae%89%e8%a3%85%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1164231.html","title":{"rendered":"\u5982\u4f55\u627epython\u7684\u5b89\u88c5\u8def\u5f84"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25204832\/430acc9c-86c7-4059-ba01-aab4f39294db.webp\" alt=\"\u5982\u4f55\u627epython\u7684\u5b89\u88c5\u8def\u5f84\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u627ePython\u7684\u5b89\u88c5\u8def\u5f84<\/strong>\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff09\u67e5\u8be2\u3001\u67e5\u770b\u73af\u5883\u53d8\u91cf\u3001\u901a\u8fc7Python\u811a\u672c\u67e5\u8be2\u3001\u5728\u7cfb\u7edf\u8bbe\u7f6e\u4e2d\u67e5\u627e\u3001\u901a\u8fc7IDE\u6216\u5f00\u53d1\u5de5\u5177\u67e5\u627e\u3002<strong>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u8be2<\/strong>\uff0c\u5728\u5927\u90e8\u5206\u7cfb\u7edf\u4e2d\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u5de5\u5177\u53ef\u4ee5\u8fc5\u901f\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165<code>where python<\/code>\u547d\u4ee4\u6765\u83b7\u53d6Python\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">where python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u547d\u4ee4\u5c06\u663e\u793aPython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u7684\u7cfb\u7edf\u4e0a\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u5b83\u4eec\u7684\u8def\u5f84\u5c06\u5168\u90e8\u5217\u51fa\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u8def\u5f84\u7c7b\u4f3c\u4e8e\uff1a<code>C:\\Python39\\python.exe<\/code>\u6216<code>C:\\Users\\&lt;YourUsername&gt;\\AppData\\Local\\Programs\\Python\\Python39\\python.exe<\/code>\u3002<\/p>\n<\/p>\n<p><p>\u5728macOS\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">which python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">which python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793aPython\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u4f8b\u5982\uff1a<code>\/usr\/local\/bin\/python3<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u8be2<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u8be2Python\u7684\u5b89\u88c5\u8def\u5f84\u662f\u6700\u76f4\u63a5\u4e5f\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u65e0\u8bba\u662fWindows\u3001macOS\u8fd8\u662fLinux\u7cfb\u7edf\uff0c\u8fd9\u79cd\u65b9\u6cd5\u90fd\u5341\u5206\u6709\u6548\u3002<\/p>\n<\/p>\n<p><h4>Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>where<\/code>\u547d\u4ee4\u6765\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08\u6309Win+R\u952e\uff0c\u8f93\u5165cmd\u5e76\u56de\u8f66\uff09\u3002<\/li>\n<li>\u8f93\u5165<code>where python<\/code>\u547d\u4ee4\uff0c\u7136\u540e\u6309Enter\u952e\u3002<\/li>\n<li>\u7cfb\u7edf\u5c06\u663e\u793a\u6240\u6709Python\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002\u5982\u679c\u5b89\u88c5\u4e86\u591a\u4e2aPython\u7248\u672c\uff0c\u6240\u6709\u8def\u5f84\u90fd\u4f1a\u5217\u51fa\u3002<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u7b80\u5355\u76f4\u63a5\uff0c\u800c\u4e14\u65e0\u9700\u989d\u5916\u5de5\u5177\u6216\u8f6f\u4ef6\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c<code>where<\/code>\u547d\u4ee4\u4ec5\u67e5\u627e\u73af\u5883\u53d8\u91cf\u8def\u5f84\u4e2d\u7684Python\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5982\u679cPython\u672a\u6b63\u786e\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5219\u6b64\u65b9\u6cd5\u53ef\u80fd\u65e0\u6cd5\u627e\u5230Python\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h4>macOS\u548cLinux\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>which<\/code>\u547d\u4ee4\u6765\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165<code>which python<\/code>\u6216<code>which python3<\/code>\u547d\u4ee4\uff0c\u7136\u540e\u6309Enter\u952e\u3002<\/li>\n<li>\u7cfb\u7edf\u5c06\u663e\u793aPython\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u4e0eWindows\u7cfb\u7edf\u4e2d\u7684<code>where<\/code>\u547d\u4ee4\u7c7b\u4f3c\uff0c\u7b80\u5355\u76f4\u63a5\uff0c\u800c\u4e14\u65e0\u9700\u989d\u5916\u5de5\u5177\u6216\u8f6f\u4ef6\u3002\u540c\u6837\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c<code>which<\/code>\u547d\u4ee4\u4ec5\u67e5\u627e\u73af\u5883\u53d8\u91cf\u8def\u5f84\u4e2d\u7684Python\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5982\u679cPython\u672a\u6b63\u786e\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5219\u6b64\u65b9\u6cd5\u53ef\u80fd\u65e0\u6cd5\u627e\u5230Python\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u67e5\u770b\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u73af\u5883\u53d8\u91cf\u662f\u64cd\u4f5c\u7cfb\u7edf\u7528\u4e8e\u5b58\u50a8\u7279\u5b9a\u7cfb\u7edf\u8def\u5f84\u548c\u914d\u7f6e\u7684\u53d8\u91cf\u3002\u901a\u5e38\uff0cPython\u7684\u5b89\u88c5\u8def\u5f84\u4f1a\u88ab\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u901a\u8fc7\u67e5\u770b\u73af\u5883\u53d8\u91cf\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h4>Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u73af\u5883\u53d8\u91cf\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\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\u3002<\/li>\n<li>\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u5e76\u53cc\u51fb\u201cPath\u201d\u53d8\u91cf\u3002<\/li>\n<li>\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u6240\u6709\u914d\u7f6e\u7684\u8def\u5f84\uff0c\u5176\u4e2d\u5e94\u8be5\u5305\u62ecPython\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u67e5\u770b\u548c\u786e\u8ba4Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u914d\u7f6e\u7684\u8def\u5f84\uff0c\u4f46\u9700\u8981\u4e00\u4e9b\u624b\u52a8\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>macOS\u548cLinux\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u73af\u5883\u53d8\u91cf\u901a\u5e38\u5b58\u50a8\u5728\u7528\u6237\u7684shell\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f8b\u5982<code>.bashrc<\/code>\u3001<code>.bash_profile<\/code>\u3001<code>.zshrc<\/code>\u7b49\u3002\u67e5\u770b\u73af\u5883\u53d8\u91cf\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u67e5\u770bPATH\u53d8\u91cf\u7684\u503c\uff1a\n<pre><code class=\"language-bash\">echo $PATH<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u7ec8\u7aef\u5c06\u663e\u793a\u6240\u6709\u914d\u7f6e\u7684\u8def\u5f84\uff0c\u5176\u4e2d\u5e94\u8be5\u5305\u62ecPython\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u67e5\u770b\u548c\u786e\u8ba4Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u914d\u7f6e\u7684\u8def\u5f84\uff0c\u4f46\u9700\u8981\u4e00\u4e9b\u624b\u52a8\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u901a\u8fc7Python\u811a\u672c\u67e5\u8be2<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u548c\u67e5\u770b\u73af\u5883\u53d8\u91cf\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u7b80\u5355\u7684Python\u811a\u672c\u6765\u67e5\u8be2Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u6240\u6709\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4e14\u975e\u5e38\u7075\u6d3b\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8bPython\u811a\u672c\uff0c\u7528\u4e8e\u67e5\u8be2Python\u7684\u5b89\u88c5\u8def\u5f84\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>print(sys.executable)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd0\u884c\u6b64\u811a\u672c\uff0c\u8f93\u51fa\u7ed3\u679c\u5c06\u663e\u793aPython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">C:\\Python39\\python.exe<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">\/usr\/local\/bin\/python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u7b80\u5355\u4e14\u8de8\u5e73\u53f0\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728Python\u73af\u5883\u4e2d\u6267\u884c\u3002\u65e0\u8bba\u662f\u5728\u547d\u4ee4\u884c\u4e2d\u8fd8\u662f\u5728IDE\u4e2d\u8fd0\u884c\u6b64\u811a\u672c\uff0c\u90fd\u53ef\u4ee5\u51c6\u786e\u83b7\u53d6Python\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5728\u7cfb\u7edf\u8bbe\u7f6e\u4e2d\u67e5\u627e<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u8bbe\u7f6e\u6216\u63a7\u5236\u9762\u677f\u6765\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u4e0d\u719f\u6089\u547d\u4ee4\u884c\u5de5\u5177\u7684\u7528\u6237\uff0c\u64cd\u4f5c\u76f8\u5bf9\u76f4\u89c2\u3002<\/p>\n<\/p>\n<p><h4>Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u63a7\u5236\u9762\u677f\u201d\u6765\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\u3002<\/li>\n<li>\u9009\u62e9\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\u3002<\/li>\n<li>\u5728\u5df2\u5b89\u88c5\u7684\u7a0b\u5e8f\u5217\u8868\u4e2d\u627e\u5230\u201cPython\u201d\uff0c\u70b9\u51fb\u53f3\u952e\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u5728\u201c\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u60a8\u53ef\u4ee5\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u76f4\u89c2\u6613\u64cd\u4f5c\uff0c\u4f46\u9700\u8981\u9010\u6b65\u67e5\u627e\u5e76\u70b9\u51fb\u591a\u4e2a\u9009\u9879\u3002<\/p>\n<\/p>\n<p><h4>macOS\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u201c\u8bbf\u8fbe\u201d\u5e94\u7528\u6765\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u8bbf\u8fbe\u201d\u3002<\/li>\n<li>\u5728\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\u4e2d\u67e5\u627e\u201cPython\u201d\u3002<\/li>\n<li>\u53f3\u952e\u70b9\u51fb\u201cPython\u201d\u56fe\u6807\uff0c\u9009\u62e9\u201c\u663e\u793a\u7b80\u4ecb\u201d\u3002<\/li>\n<li>\u5728\u201c\u7b80\u4ecb\u201d\u7a97\u53e3\u4e2d\uff0c\u60a8\u53ef\u4ee5\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u76f4\u89c2\u6613\u64cd\u4f5c\uff0c\u4f46\u9700\u8981\u9010\u6b65\u67e5\u627e\u5e76\u70b9\u51fb\u591a\u4e2a\u9009\u9879\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u901a\u8fc7IDE\u6216\u5f00\u53d1\u5de5\u5177\u67e5\u627e<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6216\u5176\u4ed6\u5f00\u53d1\u5de5\u5177\uff08\u5982PyCharm\u3001VS Code\u7b49\uff09\u8fdb\u884cPython\u5f00\u53d1\uff0c\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e9b\u5de5\u5177\u6765\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h4>PyCharm<\/h4>\n<\/p>\n<p><p>\u5728PyCharm\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00PyCharm\u3002<\/li>\n<li>\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\u3002<\/li>\n<li>\u5728\u201cSettings\u201d\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u201cProject: <YourProjectName>\u201d\u4e0b\u7684\u201cPython Interpreter\u201d\u3002<\/li>\n<li>\u5728\u53f3\u4fa7\u7a97\u53e3\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u9879\u76ee\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u65b9\u4fbf\u5feb\u6377\uff0c\u5c24\u5176\u9002\u5408\u4f7f\u7528PyCharm\u8fdb\u884c\u5f00\u53d1\u7684\u7528\u6237\u3002<\/p>\n<\/p>\n<p><h4>Visual Studio Code<\/h4>\n<\/p>\n<p><p>\u5728Visual Studio Code\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00Visual Studio Code\u3002<\/li>\n<li>\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u7684\u201cExtensions\u201d\uff0c\u786e\u4fdd\u5df2\u5b89\u88c5Python\u6269\u5c55\u3002<\/li>\n<li>\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u7684\u201cExplorer\u201d\uff0c\u6253\u5f00\u4efb\u610fPython\u6587\u4ef6\u3002<\/li>\n<li>\u70b9\u51fb\u53f3\u4e0b\u89d2\u7684Python\u7248\u672c\u53f7\uff0c\u9009\u62e9\u201cSelect Interpreter\u201d\u3002<\/li>\n<li>\u5728\u5f39\u51fa\u7684\u5217\u8868\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u6240\u6709\u53ef\u7528\u7684Python\u89e3\u91ca\u5668\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u65b9\u4fbf\u5feb\u6377\uff0c\u5c24\u5176\u9002\u5408\u4f7f\u7528VS Code\u8fdb\u884c\u5f00\u53d1\u7684\u7528\u6237\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5176\u4ed6\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u60a8\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528Python\u5305\u7ba1\u7406\u5de5\u5177<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528Python\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982pip\u6216conda\uff09\uff0c\u4e5f\u53ef\u4ee5\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u5728\u4f7f\u7528conda\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u73af\u5883\u7684Python\u8def\u5f84\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda info --envs<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda env list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u547d\u4ee4\u5c06\u663e\u793a\u6240\u6709conda\u73af\u5883\u7684\u4fe1\u606f\uff0c\u5305\u62ecPython\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h4>\u67e5\u770b\u5b89\u88c5\u65e5\u5fd7\u6216\u6587\u6863<\/h4>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Python\u65f6\uff0c\u5b89\u88c5\u7a0b\u5e8f\u901a\u5e38\u4f1a\u751f\u6210\u65e5\u5fd7\u6587\u4ef6\u6216\u6587\u6863\uff0c\u8bb0\u5f55\u5b89\u88c5\u8def\u5f84\u7b49\u4fe1\u606f\u3002\u60a8\u53ef\u4ee5\u67e5\u627e\u5e76\u67e5\u770b\u8fd9\u4e9b\u65e5\u5fd7\u6587\u4ef6\u6216\u6587\u6863\uff0c\u83b7\u53d6Python\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><p>\u603b\u4e4b\uff0c\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\u3002\u901a\u8fc7\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u8be2\u3001\u67e5\u770b\u73af\u5883\u53d8\u91cf\u3001\u901a\u8fc7Python\u811a\u672c\u67e5\u8be2\u3001\u5728\u7cfb\u7edf\u8bbe\u7f6e\u4e2d\u67e5\u627e\u3001\u901a\u8fc7IDE\u6216\u5f00\u53d1\u5de5\u5177\u67e5\u627e\u7b49\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u65b9\u4fbf\u5feb\u6377\u5730\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u6700\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u786e\u8ba4\u6211\u7535\u8111\u4e0a\u662f\u5426\u5b89\u88c5\u4e86Python\uff1f<\/strong><br \/>\u5728\u4f60\u7684\u7535\u8111\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u5de5\u5177\u6765\u786e\u8ba4Python\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u5e76\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u4f1a\u663e\u793a\u51faPython\u7684\u7248\u672c\u53f7\u3002\u5bf9\u4e8eMac\u548cLinux\u7528\u6237\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u76f8\u540c\u7684\u547d\u4ee4\u6765\u68c0\u67e5\u3002<\/p>\n<p><strong>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\uff1f<\/strong><br \/>\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u8f93\u5165<code>where python<\/code>\uff0c\u7cfb\u7edf\u5c06\u8fd4\u56dePython\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84\u3002\u6b64\u5916\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5728\u5b89\u88c5Python\u65f6\u7684\u8bbe\u7f6e\u4e2d\u67e5\u770b\u9ed8\u8ba4\u8def\u5f84\uff0c\u901a\u5e38\u662f<code>C:\\Users\\\u4f60\u7684\u7528\u6237\u540d\\AppData\\Local\\Programs\\Python\\Python\u7248\u672c\u53f7<\/code>\u3002<\/p>\n<p><strong>\u5728Mac\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u5b9a\u4f4dPython\u7684\u5b89\u88c5\u4f4d\u7f6e\uff1f<\/strong><br \/>\u5728Mac\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165<code>which python<\/code>\u6216<code>which python3<\/code>\u3002\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u8fd4\u56dePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u6b64\u5916\uff0c\u8f93\u5165<code>python -c &quot;import sys; print(sys.executable)&quot;<\/code>\u4e5f\u80fd\u663e\u793a\u5f53\u524dPython\u73af\u5883\u7684\u5b8c\u6574\u8def\u5f84\u3002\u8fd9\u5bf9\u4e8e\u786e\u8ba4\u6b63\u5728\u4f7f\u7528\u7684Python\u7248\u672c\u975e\u5e38\u6709\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff09\u67e5\u8be2\u3001\u67e5\u770b\u73af\u5883\u53d8\u91cf\u3001\u901a\u8fc7Python\u811a\u672c\u67e5\u8be2 [&hellip;]","protected":false},"author":3,"featured_media":1164237,"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\/1164231"}],"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=1164231"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1164231\/revisions"}],"predecessor-version":[{"id":1164238,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1164231\/revisions\/1164238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1164237"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1164231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1164231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1164231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}