{"id":979724,"date":"2024-12-27T06:48:49","date_gmt":"2024-12-26T22:48:49","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/979724.html"},"modified":"2024-12-27T06:48:51","modified_gmt":"2024-12-26T22:48:51","slug":"%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8bpython%e5%b7%b2%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/979724.html","title":{"rendered":"\u5982\u4f55\u67e5\u770bpython\u5df2\u5b89\u88c5"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24205424\/97dd1678-b370-41bf-ae0a-f0cdd29d4430.webp\" alt=\"\u5982\u4f55\u67e5\u770bpython\u5df2\u5b89\u88c5\" \/><\/p>\n<p><p> <strong>\u8981\u67e5\u770bPython\u662f\u5426\u5df2\u5b89\u88c5\u3001\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5Python\u7248\u672c\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668\u68c0\u67e5\u3001\u5728\u64cd\u4f5c\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u67e5\u627ePython\u8def\u5f84\u3002<\/strong>\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u547d\u4ee4\u884c\u6765\u68c0\u67e5Python\u7684\u7248\u672c\uff0c\u8fd9\u662f\u56e0\u4e3a\u5b83\u7b80\u5355\u4e14\u76f4\u63a5\u3002\u4f60\u53ea\u9700\u8981\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\uff0c\u8f93\u5165\u7279\u5b9a\u7684\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u8f7b\u677e\u67e5\u770b\u5230Python\u662f\u5426\u5df2\u5b89\u88c5\u53ca\u5176\u7248\u672c\u4fe1\u606f\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5982\u4f55\u6267\u884c\u8fd9\u4e9b\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5Python\u7248\u672c<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows\u7cfb\u7edf\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u6765\u68c0\u67e5Python\u662f\u5426\u5b89\u88c5\u3002\u9996\u5148\uff0c\u6309\u4e0b\u201cWin + R\u201d\u952e\u6253\u5f00\u8fd0\u884c\u7a97\u53e3\uff0c\u8f93\u5165\u201ccmd\u201d\u5e76\u6309\u4e0b\u56de\u8f66\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u3002\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -V<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u7cfb\u7edf\u5c06\u8fd4\u56dePython\u7684\u7248\u672c\u53f7\uff0c\u4f8b\u5982\u201cPython 3.8.5\u201d\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u5219\u4f1a\u51fa\u73b0\u9519\u8bef\u63d0\u793a\uff0c\u8bf4\u660e\u201c\u2018python\u2019 \u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4\uff0c\u4e5f\u4e0d\u662f\u53ef\u8fd0\u884c\u7684\u7a0b\u5e8f\u6216\u6279\u5904\u7406\u6587\u4ef6\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>macOS\u548cLinux\u7cfb\u7edf\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5728macOS\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u6765\u68c0\u67e5Python\u7684\u5b89\u88c5\u60c5\u51b5\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>macOS\u548cLinux\u7cfb\u7edf\u901a\u5e38\u4f1a\u9884\u88c5Python 2.x\u7248\u672c\uff0c\u56e0\u6b64\u68c0\u67e5Python 3.x\u7248\u672c\u65f6\u9700\u8981\u4f7f\u7528\u201cpython3\u201d\u547d\u4ee4\u3002\u5982\u679c\u5df2\u5b89\u88c5Python\uff0c\u7ec8\u7aef\u4f1a\u8fd4\u56de\u76f8\u5e94\u7684\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u53ef\u80fd\u4f1a\u63d0\u793a\u201ccommand not found\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668\u68c0\u67e5<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u76f4\u63a5\u542f\u52a8Python\u89e3\u91ca\u5668\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u547d\u4ee4\u884c\u4f1a\u8fdb\u5165Python\u89e3\u91ca\u5668\u73af\u5883\uff0c\u5e76\u663e\u793aPython\u7684\u7248\u672c\u4fe1\u606f\uff0c\u4f8b\u5982\u201cPython 3.8.5\u201d\u3002\u4f60\u53ef\u4ee5\u5728\u89e3\u91ca\u5668\u4e2d\u8f93\u5165\u7b80\u5355\u7684Python\u4ee3\u7801\u6765\u9a8c\u8bc1\u5176\u529f\u80fd\u3002\u5982\u679cPython\u672a\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u5728\u64cd\u4f5c\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u67e5\u627ePython\u8def\u5f84<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows\u7cfb\u7edf\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u73af\u5883\u53d8\u91cf\u6765\u68c0\u67e5Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u56fe\u6807\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u9009\u62e9\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u6216\u201c\u7528\u6237\u53d8\u91cf\u201d\u4e2d\u67e5\u627e\u540d\u4e3a\u201cPath\u201d\u7684\u53d8\u91cf\uff0c\u53cc\u51fb\u6253\u5f00\u540e\u67e5\u770b\u5176\u4e2d\u662f\u5426\u5305\u542bPython\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u4f8b\u5982\u201cC:\\Python38\u201d\u6216\u201cC:\\Users\\YourUsername\\AppData\\Local\\Programs\\Python\\Python38\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>macOS\u548cLinux\u7cfb\u7edf\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u67e5\u770bPython\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5728\u7ec8\u7aef\u4e2d\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\u8005\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">which python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8fd4\u56dePython\u89e3\u91ca\u5668\u7684\u8def\u5f84\uff0c\u4f8b\u5982\u201c\/usr\/bin\/python3\u201d\u3002\u5982\u679c\u672a\u5b89\u88c5Python\uff0c\u547d\u4ee4\u5c06\u4e0d\u4f1a\u8fd4\u56de\u4efb\u4f55\u7ed3\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u68c0\u67e5Python\u5305\u7ba1\u7406\u5668pip<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9a8c\u8bc1pip\u662f\u5426\u5b89\u88c5\uff1a<\/strong><\/p>\n<\/p>\n<p><p>pip\u662fPython\u7684\u5305\u7ba1\u7406\u5668\uff0c\u901a\u5e38\u4e0ePython\u4e00\u8d77\u5b89\u88c5\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5pip\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679cpip\u5df2\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u8fd4\u56depip\u7684\u7248\u672c\u4fe1\u606f\u548cPython\u7684\u7248\u672c\u8def\u5f84\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u53ef\u80fd\u4f1a\u63d0\u793a\u201ccommand not found\u201d\u6216\u7c7b\u4f3c\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5pip\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679cPython\u5df2\u5b89\u88c5\u4f46pip\u672a\u5b89\u88c5\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5pip\uff1a<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8ePython 3.x\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m ensurepip --upgrade<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m ensurepip --upgrade<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684pip\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5728IDE\u4e2d\u67e5\u770bPython\u914d\u7f6e\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u8bb8\u591a\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u5982PyCharm\u3001Visual Studio Code\u548cAnaconda\u90fd\u5141\u8bb8\u4f60\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002\u5728\u8fd9\u4e9bIDE\u4e2d\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u67e5\u770b\u6216\u9009\u62e9Python\u89e3\u91ca\u5668\u7684\u8def\u5f84\u548c\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5728PyCharm\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u201cFile\u201d -&gt; \u201cSettings\u201d -&gt; \u201cProject: ProjectName\u201d -&gt; \u201cPython Interpreter\u201d\u6765\u67e5\u770b\u548c\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528IDE\u7684\u7ec8\u7aef\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u4f60\u4e5f\u53ef\u4ee5\u5728IDE\u81ea\u5e26\u7684\u7ec8\u7aef\u4e2d\u8fd0\u884c\u547d\u4ee4\u6765\u68c0\u67e5Python\u548cpip\u7684\u7248\u672c\uff0c\u8fd9\u4e0e\u5728\u64cd\u4f5c\u7cfb\u7edf\u7684\u547d\u4ee4\u884c\u4e2d\u6267\u884c\u7684\u6b65\u9aa4\u76f8\u540c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u68c0\u67e5Python\u5b89\u88c5\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u67e5\u770b\u5b89\u88c5\u76ee\u5f55\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u77e5\u9053Python\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u53ef\u4ee5\u76f4\u63a5\u67e5\u770b\u8be5\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u548c\u6587\u4ef6\u5939\u3002\u901a\u5e38\uff0cPython\u7684\u5b89\u88c5\u76ee\u5f55\u4e0b\u4f1a\u5305\u542bpython.exe\uff08\u5728Windows\u4e0a\uff09\u6216python\uff08\u5728macOS\u548cLinux\u4e0a\uff09\u6587\u4ef6\uff0c\u4ee5\u53caLib\u3001Scripts\u7b49\u6587\u4ef6\u5939\u3002<\/p>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u53cc\u51fbpython.exe\u6587\u4ef6\u6765\u542f\u52a8Python\u89e3\u91ca\u5668\uff0c\u4ee5\u9a8c\u8bc1\u5176\u662f\u5426\u80fd\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5Python\u5e93\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u76ee\u5f55\u4e2d\u7684Lib\u6587\u4ef6\u5939\u4e0b\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\u3002\u8fd9\u6709\u52a9\u4e8e\u4f60\u4e86\u89e3Python\u73af\u5883\u4e2d\u53ef\u7528\u7684\u6a21\u5757\u548c\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u5728\u865a\u62df\u73af\u5883\u4e2d\u68c0\u67e5Python<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406Python\u9879\u76ee\uff0c\u53ef\u4ee5\u901a\u8fc7\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u6765\u68c0\u67e5\u5176\u4e2d\u7684Python\u7248\u672c\u3002\u9996\u5148\uff0c\u5bfc\u822a\u5230\u865a\u62df\u73af\u5883\u7684\u76ee\u5f55\uff0c\u7136\u540e\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u73af\u5883\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>Windows\uff1a<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\\venv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>macOS\u548cLinux\uff1a<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source venv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u865a\u62df\u73af\u5883\u4e2d\u7684Python\u7248\u672c\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8fd4\u56de\u865a\u62df\u73af\u5883\u4e2dPython\u7684\u7248\u672c\u4fe1\u606f\u3002\u865a\u62df\u73af\u5883\u5141\u8bb8\u4f60\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u591a\u4e2a\u4e0d\u540c\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516b\u3001\u4f7f\u7528Python\u811a\u672c\u68c0\u67e5<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f16\u5199Python\u811a\u672c\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u6765\u68c0\u67e5Python\u7684\u7248\u672c\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3acheck_python_version.py\u7684\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>print(&quot;Python version&quot;)<\/p>\n<p>print(sys.version)<\/p>\n<p>print(&quot;Version info.&quot;)<\/p>\n<p>print(sys.version_info)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u811a\u672c\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8fd0\u884c\u8be5\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python check_python_version.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 check_python_version.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u811a\u672c\u5c06\u8f93\u51fa\u5f53\u524dPython\u7684\u7248\u672c\u4fe1\u606f\u548c\u8be6\u7ec6\u7684\u7248\u672c\u4fe1\u606f\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e5d\u3001\u4f7f\u7528Python\u5305\u7ba1\u7406\u5de5\u5177<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528Anaconda\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u4f7f\u7528Anaconda\u4f5c\u4e3aPython\u7684\u5305\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7Anaconda Navigator\u6216conda\u547d\u4ee4\u884c\u5de5\u5177\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u901a\u8fc7Conda\u5b89\u88c5\u7684\u5305\uff0c\u5176\u4e2d\u5305\u62ecPython\u7684\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pipenv\uff1a<\/strong><\/p>\n<\/p>\n<p><p>pipenv\u662f\u4e00\u4e2aPython\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u4f7f\u7528Pipfile\u6765\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u9879\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u9879\u76ee\u4e2d\u4f7f\u7528\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pipenv --py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8fd4\u56depipenv\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u7684\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4ee5\u4e0a\u662f\u67e5\u770bPython\u662f\u5426\u5df2\u5b89\u88c5\u7684\u591a\u79cd\u65b9\u6cd5\u3002\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u5f00\u53d1\u73af\u5883\u9009\u62e9\u9002\u5408\u7684\u65b9\u6cd5\u6765\u68c0\u67e5Python\u7684\u5b89\u88c5\u72b6\u6001\u548c\u7248\u672c\u4fe1\u606f\u3002\u65e0\u8bba\u662f\u901a\u8fc7\u547d\u4ee4\u884c\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\u3001\u865a\u62df\u73af\u5883\u8fd8\u662f\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u80fd\u5e2e\u52a9\u4f60\u5feb\u901f\u4e86\u89e3Python\u7684\u5b89\u88c5\u60c5\u51b5\u3002\u786e\u4fddPython\u548c\u76f8\u5173\u5de5\u5177\u6b63\u786e\u5b89\u88c5\uff0c\u5bf9\u4e8e\u987a\u5229\u5f00\u5c55Python\u5f00\u53d1\u5de5\u4f5c\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u786e\u8ba4\u6211\u7684\u7535\u8111\u4e0a\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u754c\u9762\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u68c0\u67e5Python\u7684\u5b89\u88c5\u72b6\u6001\u3002\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230\u5f53\u524d\u7248\u672c\u53f7\u7684\u8f93\u51fa\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u65e0\u6cd5\u627e\u5230\u8be5\u547d\u4ee4\u3002<\/p>\n<p><strong>\u6211\u5e94\u8be5\u5982\u4f55\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u67e5\u770bPython\u5b89\u88c5\u60c5\u51b5\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u60a8\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5e76\u8f93\u5165<code>python<\/code>\u6216<code>py<\/code>\u6765\u67e5\u770b\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u76f8\u540c\u7684\u547d\u4ee4\u5373\u53ef\u3002\u5982\u679c\u60a8\u770b\u5230Python\u7684\u7248\u672c\u4fe1\u606f\uff0c\u8bf4\u660e\u5b83\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u7684\u7535\u8111\u4e0a\u6ca1\u6709\u5b89\u88c5Python\uff0c\u6211\u5e94\u8be5\u5982\u4f55\u5b89\u88c5\u5b83\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u518d\u6b21\u901a\u8fc7\u547d\u4ee4\u884c\u786e\u8ba4\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u67e5\u770bPython\u662f\u5426\u5df2\u5b89\u88c5\u3001\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5Python\u7248\u672c\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668\u68c0\u67e5\u3001\u5728\u64cd\u4f5c\u7cfb\u7edf\u7684\u73af\u5883 [&hellip;]","protected":false},"author":3,"featured_media":979727,"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\/979724"}],"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=979724"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/979724\/revisions"}],"predecessor-version":[{"id":979729,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/979724\/revisions\/979729"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/979727"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=979724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=979724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=979724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}