{"id":968711,"date":"2024-12-27T05:09:33","date_gmt":"2024-12-26T21:09:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/968711.html"},"modified":"2024-12-27T05:09:35","modified_gmt":"2024-12-26T21:09:35","slug":"python%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%ae%e5%ae%89%e8%a3%85%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/968711.html","title":{"rendered":"python\u5982\u4f55\u8bbe\u7f6e\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\/24183339\/9e4e7574-dccd-40b5-b98d-68947e5a55f7.webp\" alt=\"python\u5982\u4f55\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84\" \/><\/p>\n<p><p> \u4e00\u3001\u5728Python\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84\u7684\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Python\u65f6\uff0c<strong>\u901a\u8fc7\u81ea\u5b9a\u4e49\u5b89\u88c5\u9009\u9879\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5b89\u88c5\u5e76\u6307\u5b9a\u8def\u5f84\u3001\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u914d\u7f6ePython\u8def\u5f84<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u901a\u8fc7\u81ea\u5b9a\u4e49\u5b89\u88c5\u9009\u9879\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84<\/strong>\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u3002\u5728\u5b89\u88c5Python\u65f6\uff0c\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u63d0\u4f9b\u4e00\u4e2a\u9ed8\u8ba4\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u4f46\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u9009\u62e9\u81ea\u5b9a\u4e49\u5b89\u88c5\u6765\u66f4\u6539\u6b64\u8def\u5f84\u3002\u9009\u62e9\u81ea\u5b9a\u4e49\u5b89\u88c5\u540e\uff0c\u7528\u6237\u53ef\u4ee5\u624b\u52a8\u8f93\u5165\u6216\u6d4f\u89c8\u9009\u62e9\u4ed6\u4eec\u5e0c\u671b\u7684\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u76f4\u63a5\uff0c\u9002\u5408\u5927\u591a\u6570\u7528\u6237\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u901a\u8fc7\u81ea\u5b9a\u4e49\u5b89\u88c5\u9009\u9879\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Python\u7684\u8fc7\u7a0b\u4e2d\uff0c\u7528\u6237\u901a\u5e38\u4f1a\u770b\u5230\u4e00\u4e2a\u9ed8\u8ba4\u7684\u5b89\u88c5\u9009\u9879\u3002\u7136\u800c\uff0c\u5982\u679c\u60a8\u9700\u8981\u5c06Python\u5b89\u88c5\u5728\u7279\u5b9a\u7684\u76ee\u5f55\u4e2d\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u81ea\u5b9a\u4e49\u5b89\u88c5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u9996\u5148\uff0c\u4e0b\u8f7dPython\u5b89\u88c5\u7a0b\u5e8f\u5e76\u8fd0\u884c\u5b83\u3002\u5728\u5b89\u88c5\u5411\u5bfc\u7684\u521d\u59cb\u754c\u9762\u4e0a\uff0c\u901a\u5e38\u4f1a\u770b\u5230\u4e00\u4e2a\u201cCustomize installation\u201d\uff08\u81ea\u5b9a\u4e49\u5b89\u88c5\uff09\u7684\u9009\u9879\u3002\u9009\u62e9\u8fd9\u4e2a\u9009\u9879\u540e\uff0c\u60a8\u53ef\u4ee5\u8fdb\u5165\u4e00\u4e2a\u65b0\u7684\u754c\u9762\uff0c\u5728\u90a3\u91cc\u60a8\u53ef\u4ee5\u9009\u62e9\u4e0d\u540c\u7684\u5b89\u88c5\u7ec4\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5728\u81ea\u5b9a\u4e49\u5b89\u88c5\u754c\u9762\u4e2d\uff0c\u60a8\u4f1a\u770b\u5230\u4e00\u4e2a\u7528\u4e8e\u9009\u62e9\u5b89\u88c5\u8def\u5f84\u7684\u9009\u9879\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165\u8def\u5f84\u6216\u4f7f\u7528\u6d4f\u89c8\u529f\u80fd\u9009\u62e9\u60a8\u5e0c\u671b\u7684\u5b89\u88c5\u76ee\u5f55\u3002\u786e\u4fdd\u60a8\u9009\u62e9\u7684\u76ee\u5f55\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u5e76\u4e14\u662f\u60a8\u6709\u8bbf\u95ee\u6743\u9650\u7684\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5b8c\u6210\u8def\u5f84\u9009\u62e9\u540e\uff0c\u7ee7\u7eed\u6309\u7167\u5411\u5bfc\u5b8c\u6210\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0cPython\u5c06\u88ab\u5b89\u88c5\u5728\u60a8\u6307\u5b9a\u7684\u76ee\u5f55\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5b89\u88c5\u5e76\u6307\u5b9a\u8def\u5f84<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u66f4\u9ad8\u7ea7\u7684\u7528\u6237\uff0c\u5c24\u5176\u662f\u5728Linux\u6216macOS\u73af\u5883\u4e0b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u8fdb\u884c\u5b89\u88c5\u5e76\u6307\u5b9a\u8def\u5f84\u3002\u8fd9\u901a\u5e38\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u6216\u76f4\u63a5\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668<\/strong>\uff1a\u5728Linux\u7cfb\u7edf\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5982apt\u6216yum\u6765\u5b89\u88c5Python\uff0c\u540c\u65f6\u6307\u5b9a\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u4f7f\u7528apt\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u6216\u914d\u7f6e\u6587\u4ef6\u6765\u66f4\u6539\u9ed8\u8ba4\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1<\/strong>\uff1a\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5Python\u3002\u8fd9\u79cd\u65b9\u6cd5\u63d0\u4f9b\u4e86\u6700\u5927\u7684\u7075\u6d3b\u6027\u3002\u9996\u5148\uff0c\u4e0b\u8f7dPython\u7684\u6e90\u4ee3\u7801\u538b\u7f29\u5305\u5e76\u89e3\u538b\u3002\u7136\u540e\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u8fdb\u5165\u89e3\u538b\u76ee\u5f55\u5e76\u8fd0\u884c<code>.\/configure --prefix=\/desired\/path<\/code>\uff0c\u5176\u4e2d<code>\/desired\/path<\/code>\u662f\u60a8\u60f3\u8981\u5b89\u88c5Python\u7684\u76ee\u5f55\u3002\u63a5\u4e0b\u6765\uff0c\u8fd0\u884c<code>make<\/code>\u548c<code>make install<\/code>\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u914d\u7f6ePython\u8def\u5f84<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u60a8\u9009\u62e9\u54ea\u79cd\u5b89\u88c5\u65b9\u6cd5\uff0c\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u90fd\u662f\u786e\u4fddPython\u6b63\u786e\u8fd0\u884c\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u8fd9\u901a\u5e38\u5305\u62ec\u8bbe\u7f6ePATH\u53d8\u91cf\u548cPYTHONPATH\u53d8\u91cf\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbe\u7f6ePATH\u53d8\u91cf<\/strong>\uff1a\u786e\u4fdd\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u80fd\u591f\u627e\u5230Python\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u60a8\u9700\u8981\u5c06Python\u7684\u5b89\u88c5\u76ee\u5f55\u6dfb\u52a0\u5230PATH\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u5728Windows\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u5c5e\u6027\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6765\u8fdb\u884c\u3002\u5728Linux\u548cmacOS\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u6765\u6dfb\u52a0\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6ePYTHONPATH\u53d8\u91cf<\/strong>\uff1a\u5982\u679c\u60a8\u6709\u591a\u4e2aPython\u7248\u672c\u6216\u5e93\u8def\u5f84\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u914d\u7f6ePYTHONPATH\u73af\u5883\u53d8\u91cf\u4ee5\u6307\u5b9aPython\u89e3\u91ca\u5668\u5e94\u8be5\u67e5\u627e\u6a21\u5757\u7684\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u7684\u5b89\u88c5\u8def\u5f84\u8bbe\u7f6e<\/p>\n<\/p>\n<p><p>Python\u7684\u5b89\u88c5\u8def\u5f84\u8bbe\u7f6e\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u53ef\u80fd\u7565\u6709\u4e0d\u540c\uff0c\u4e86\u89e3\u8fd9\u4e9b\u5dee\u5f02\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7ba1\u7406Python\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows<\/strong>\uff1a\u5728Windows\u4e0a\uff0cPython\u901a\u5e38\u9ed8\u8ba4\u5b89\u88c5\u5728<code>C:\\Users\\&lt;YourUserName&gt;\\AppData\\Local\\Programs\\Python\\Python&lt;version&gt;<\/code>\u3002\u901a\u8fc7\u5b89\u88c5\u5411\u5bfc\u7684\u81ea\u5b9a\u4e49\u9009\u9879\uff0c\u60a8\u53ef\u4ee5\u5c06\u5176\u5b89\u88c5\u5728\u5176\u4ed6\u4f4d\u7f6e\u3002\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Linux<\/strong>\uff1a\u5728Linux\u7cfb\u7edf\u4e0a\uff0cPython\u901a\u5e38\u662f\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u7684\uff0c\u9ed8\u8ba4\u8def\u5f84\u901a\u5e38\u5728<code>\/usr\/bin<\/code>\u6216<code>\/usr\/local\/bin<\/code>\u4e0b\u3002\u901a\u8fc7\u6e90\u4ee3\u7801\u5b89\u88c5\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>--prefix<\/code>\u9009\u9879\u6307\u5b9a\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>macOS<\/strong>\uff1a\u5728macOS\u4e0a\uff0cPython\u53ef\u80fd\u5df2\u7ecf\u9884\u5b89\u88c5\u4e86\u65e7\u7248\u672c\u3002\u7528\u6237\u901a\u5e38\u901a\u8fc7Homebrew\u7b49\u5de5\u5177\u5b89\u88c5\u65b0\u7248\u672c\uff0c\u9ed8\u8ba4\u8def\u5f84\u901a\u5e38\u5728<code>\/usr\/local\/bin<\/code>\u4e0b\u3002\u901a\u8fc7Homebrew\u5b89\u88c5\u65f6\uff0c\u8def\u5f84\u53ef\u4ee5\u901a\u8fc7Homebrew\u7684\u914d\u7f6e\u8fdb\u884c\u66f4\u6539\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u5b89\u88c5\u540e\u9a8c\u8bc1Python\u8def\u5f84\u8bbe\u7f6e<\/p>\n<\/p>\n<p><p>\u5b89\u88c5Python\u5e76\u8bbe\u7f6e\u8def\u5f84\u540e\uff0c\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u662f\u91cd\u8981\u7684\u4e00\u6b65\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u51e0\u4e2a\u7b80\u5355\u7684\u547d\u4ee4\u6765\u5b8c\u6210\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9a8c\u8bc1Python\u7248\u672c<\/strong>\uff1a\u6253\u5f00\u547d\u4ee4\u884c\uff08\u6216\u7ec8\u7aef\uff09\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u6839\u636e\u60a8\u5b89\u88c5\u7684\u7248\u672c\u3002\u5982\u679c\u8def\u5f84\u8bbe\u7f6e\u6b63\u786e\uff0c\u60a8\u5e94\u8be5\u4f1a\u770b\u5230\u60a8\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1pip\u5b89\u88c5<\/strong>\uff1apip\u662fPython\u7684\u5305\u7ba1\u7406\u5668\uff0c\u901a\u5e38\u4e0ePython\u4e00\u8d77\u5b89\u88c5\u3002\u8f93\u5165<code>pip --version<\/code>\u6216<code>pip3 --version<\/code>\u6765\u9a8c\u8bc1pip\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u7b80\u5355\u7684Python\u811a\u672c<\/strong>\uff1a\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u6587\u4ef6\uff0c\u4f8b\u5982<code>hello.py<\/code>\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, Python!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>python hello.py<\/code>\u6216<code>python3 hello.py<\/code>\u3002\u5982\u679c\u8f93\u51fa\u201cHello, Python!\u201d\uff0c\u8bf4\u660ePython\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u5e76\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002\u8fd9\u9700\u8981\u66f4\u590d\u6742\u7684\u8def\u5f84\u7ba1\u7406\u548c\u5de5\u5177\u652f\u6301\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528pyenv<\/strong>\uff1apyenv\u662f\u4e00\u4e2a\u6d41\u884c\u7684Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u5141\u8bb8\u60a8\u8f7b\u677e\u5b89\u88c5\u548c\u5207\u6362\u591a\u4e2aPython\u7248\u672c\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7pyenv\u7684\u547d\u4ee4\u6765\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684Python\uff0c\u5e76\u4e3a\u4e0d\u540c\u7684\u9879\u76ee\u8bbe\u7f6e\u4e0d\u540c\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u865a\u62df\u73af\u5883<\/strong>\uff1aPython\u7684\u865a\u62df\u73af\u5883\u5141\u8bb8\u60a8\u4e3a\u4e0d\u540c\u7684\u9879\u76ee\u521b\u5efa\u9694\u79bb\u7684Python\u73af\u5883\u3002\u8fd9\u4e0d\u4ec5\u53ef\u4ee5\u5e2e\u52a9\u60a8\u7ba1\u7406\u4e0d\u540c\u7684\u5e93\u7248\u672c\uff0c\u8fd8\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u73af\u5883\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684Python\u7248\u672c\u3002\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u6216<code>virtualenv<\/code>\u5de5\u5177\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516b\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u4e3aPython\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84\u662f\u786e\u4fddPython\u73af\u5883\u6b63\u786e\u914d\u7f6e\u7684\u91cd\u8981\u6b65\u9aa4\u3002<strong>\u901a\u8fc7\u81ea\u5b9a\u4e49\u5b89\u88c5\u9009\u9879\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5b89\u88c5\u5e76\u6307\u5b9a\u8def\u5f84\u3001\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u914d\u7f6ePython\u8def\u5f84<\/strong>\u662f\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u6709\u6548\u65b9\u6cd5\u3002\u65e0\u8bba\u60a8\u662f\u521d\u5b66\u8005\u8fd8\u662f\u7ecf\u9a8c\u4e30\u5bcc\u7684\u5f00\u53d1\u8005\uff0c\u4e86\u89e3\u8fd9\u4e9b\u6b65\u9aa4\u548c\u5de5\u5177\u90fd\u5c06\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7ba1\u7406Python\u73af\u5883\u3002\u901a\u8fc7\u9a8c\u8bc1\u5b89\u88c5\u548c\u8def\u5f84\u8bbe\u7f6e\u7684\u6b63\u786e\u6027\uff0c\u53ef\u4ee5\u786e\u4fdd\u60a8\u7684\u5f00\u53d1\u73af\u5883\u9ad8\u6548\u4e14\u65e0\u6545\u969c\u5730\u8fd0\u884c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u7684Python\u5b89\u88c5\u8def\u5f84\uff1f<\/strong><br \/>\u5728\u5b89\u88c5Python\u65f6\uff0c\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u5b89\u88c5\u8def\u5f84\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u5efa\u8bae\u9009\u62e9\u4e00\u4e2a\u6613\u4e8e\u8bbf\u95ee\u7684\u4f4d\u7f6e\uff0c\u4f8b\u5982\u5728\u7528\u6237\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cPython\u201d\u7684\u6587\u4ef6\u5939\u3002\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u4ee5\u540e\u8fdb\u884c\u7ba1\u7406\u548c\u67e5\u627e\uff0c\u540c\u65f6\u907f\u514d\u4e0e\u7cfb\u7edf\u6587\u4ef6\u53d1\u751f\u51b2\u7a81\u3002<\/p>\n<p><strong>\u5728Windows\u7cfb\u7edf\u4e2d\u5982\u4f55\u66f4\u6539Python\u7684\u9ed8\u8ba4\u5b89\u88c5\u8def\u5f84\uff1f<\/strong><br \/>\u5728Windows\u4e0a\u5b89\u88c5Python\u65f6\uff0c\u53ef\u4ee5\u5728\u5b89\u88c5\u7a0b\u5e8f\u7684\u81ea\u5b9a\u4e49\u5b89\u88c5\u9009\u9879\u4e2d\u9009\u62e9\u201cCustomize installation\u201d\uff0c\u7136\u540e\u5728\u201cAdvanced Options\u201d\u4e2d\u627e\u5230\u201cInstall for all users\u201d\u6216\u201cInstall to\u201d\u9009\u9879\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165\u60a8\u5e0c\u671b\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u786e\u4fdd\u9009\u62e9\u7684\u4f4d\u7f6e\u6ca1\u6709\u6743\u9650\u9650\u5236\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u5728Linux\u6216MacOS\u4e0a\u66f4\u6539Python\u7684\u5b89\u88c5\u8def\u5f84\uff1f<\/strong><br \/>\u5728Linux\u6216MacOS\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982apt\u3001yum\u6216brew\uff09\u6765\u5b89\u88c5Python\u3002\u5bf9\u4e8e\u81ea\u5b9a\u4e49\u5b89\u88c5\uff0c\u53ef\u4ee5\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1Python\uff0c\u4f7f\u7528\u547d\u4ee4<code>.\/configure --prefix=\/desired\/path<\/code>\u6765\u6307\u5b9a\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u5c06\u4f7f\u60a8\u80fd\u591f\u5c06Python\u5b89\u88c5\u5230\u6307\u5b9a\u76ee\u5f55\uff0c\u800c\u4e0d\u662f\u9ed8\u8ba4\u7684\u7cfb\u7edf\u8def\u5f84\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u5b89\u88c5\u540e\u786e\u8ba4Python\u7684\u5b89\u88c5\u8def\u5f84\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>which python<\/code>\uff08Linux\/MacOS\uff09\u6216<code>where python<\/code>\uff08Windows\uff09\u6765\u67e5\u627ePython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\uff0c\u8f93\u5165<code>import sys<\/code>\u548c<code>print(sys.executable)<\/code>\u6765\u83b7\u53d6\u5f53\u524dPython\u89e3\u91ca\u5668\u7684\u786e\u5207\u8def\u5f84\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u5728\u540c\u4e00\u53f0\u7535\u8111\u4e0a\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u60a8\u53ef\u4ee5\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c\u3002\u4e3a\u907f\u514d\u51b2\u7a81\uff0c\u5efa\u8bae\u4e3a\u6bcf\u4e2a\u7248\u672c\u9009\u62e9\u4e0d\u540c\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u5e76\u4f7f\u7528\u865a\u62df\u73af\u5883\u5de5\u5177\uff08\u5982venv\u6216conda\uff09\u6765\u7ba1\u7406\u5404\u4e2a\u7248\u672c\u53ca\u5176\u4f9d\u8d56\u5305\u3002\u8fd9\u5c06\u4f7f\u60a8\u80fd\u591f\u5728\u4e0d\u540c\u7684\u9879\u76ee\u4e2d\u7075\u6d3b\u4f7f\u7528\u4e0d\u540c\u7684Python\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001\u5728Python\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84\u7684\u65b9\u6cd5 \u5728\u5b89\u88c5Python\u65f6\uff0c\u901a\u8fc7\u81ea\u5b9a\u4e49\u5b89\u88c5\u9009\u9879\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84\u3001\u4f7f\u7528\u547d\u4ee4 [&hellip;]","protected":false},"author":3,"featured_media":968719,"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\/968711"}],"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=968711"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/968711\/revisions"}],"predecessor-version":[{"id":968721,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/968711\/revisions\/968721"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/968719"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=968711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=968711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=968711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}