{"id":984124,"date":"2024-12-27T07:25:21","date_gmt":"2024-12-26T23:25:21","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/984124.html"},"modified":"2024-12-27T07:25:24","modified_gmt":"2024-12-26T23:25:24","slug":"%e5%a6%82%e4%bd%95%e4%b8%8b%e8%bd%bdpython2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/984124.html","title":{"rendered":"\u5982\u4f55\u4e0b\u8f7dpython2"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24211835\/3c3f3878-00f9-4d71-bb14-f19c0072848b.webp\" alt=\"\u5982\u4f55\u4e0b\u8f7dpython2\" \/><\/p>\n<p><p> <strong>\u8981\u4e0b\u8f7dPython 2\uff0c\u9996\u5148\u9700\u8981\u660e\u786ePython 2\u5df2\u7ecf\u505c\u6b62\u5b98\u65b9\u652f\u6301\uff0c\u56e0\u6b64\u4e0d\u5efa\u8bae\u5728\u65b0\u9879\u76ee\u4e2d\u4f7f\u7528\u5b83\u3002\u4e0d\u8fc7\uff0c\u5982\u679c\u60a8\u786e\u5b9e\u9700\u8981\u4e0b\u8f7dPython 2\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b98\u65b9\u7f51\u7ad9\u65e7\u7248\u672c\u9875\u9762\u3001\u7b2c\u4e09\u65b9\u7f51\u7ad9\u955c\u50cf\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u7b49\u65b9\u5f0f\u83b7\u53d6\u3002\u4e3a\u4e86\u4fdd\u969c\u5b89\u5168\uff0c\u5efa\u8bae\u4ece\u5b98\u65b9\u6e20\u9053\u6216\u53d7\u4fe1\u4efb\u7684\u955c\u50cf\u7ad9\u4e0b\u8f7d\uff0c\u5e76\u6ce8\u610f\u5b89\u88c5\u540e\u4e0d\u8981\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d<\/p>\n<\/p>\n<p><p>Python\u5b98\u65b9\u7f51\u7ad9\u63d0\u4f9b\u4e86\u5386\u53f2\u7248\u672c\u7684\u4e0b\u8f7d\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cPython 2.x\u7684\u66f4\u65b0\u4e0e\u652f\u6301\u5df2\u4e8e2020\u5e741\u6708\u6b63\u5f0f\u7ed3\u675f\u3002\u56e0\u6b64\uff0c\u5982\u679c\u9700\u8981\u4e0b\u8f7dPython 2\uff0c\u60a8\u9700\u8981\u8bbf\u95eePython\u7684\u65e7\u7248\u672c\u4e0b\u8f7d\u9875\u9762\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbf\u95eePython\u5b98\u7f51<\/strong><br \/>\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00Python\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\uff0c\u5728\u9876\u90e8\u5bfc\u822a\u680f\u627e\u5230\u201cDownloads\u201d\u9009\u9879\uff0c\u7136\u540e\u9009\u62e9\u201cView the full list of downloads\u201d\u4ee5\u6d4f\u89c8\u6240\u6709\u53ef\u7528\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9Python 2\u7248\u672c<\/strong><br \/>\u5728\u4e0b\u8f7d\u9875\u9762\uff0c\u5411\u4e0b\u6eda\u52a8\uff0c\u627e\u5230\u201cPython 2.7.x\u201d\u7cfb\u5217\u3002\u5c3d\u7ba1\u6709\u591a\u4e2a\u5c0f\u7248\u672c\uff0c\u901a\u5e38\u5efa\u8bae\u9009\u62e92.7.18\uff0c\u8fd9\u662fPython 2\u7684\u6700\u540e\u4e00\u4e2a\u6b63\u5f0f\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u64cd\u4f5c\u7cfb\u7edf<\/strong><br \/>\u6839\u636e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5408\u9002\u7684\u5b89\u88c5\u5305\u3002\u5b98\u7f51\u901a\u5e38\u63d0\u4f9bWindows\u3001macOS\u548c\u6e90\u7801\u6587\u4ef6\u4f9b\u4e0b\u8f7d\u3002\u9009\u62e9\u540e\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5<\/strong><br \/>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\u3002\u5728Windows\u4e0a\uff0c\u76f4\u63a5\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728macOS\u6216Linux\u4e0a\uff0c\u53ef\u80fd\u9700\u8981\u4ece\u6e90\u7801\u7f16\u8bd1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\u5b89\u88c5<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u6765\u5b89\u88c5Python 2\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u66f4\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406Python\u7248\u672c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528Homebrew\uff08macOS\uff09<\/strong><br \/>Homebrew\u662fmacOS\u4e0a\u7684\u4e00\u6b3e\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b89\u88c5Python 2\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python@2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8bf7\u6ce8\u610f\uff0cHomebrew\u53ef\u80fd\u4f1a\u968f\u7740\u65f6\u95f4\u63a8\u79fb\u4e0d\u518d\u63d0\u4f9bPython 2\u7684\u5b89\u88c5\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528APT\uff08Ubuntu\uff09<\/strong><br \/>\u5728Ubuntu\u4e0a\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7APT\u5305\u7ba1\u7406\u5de5\u5177\u5b89\u88c5Python 2\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update<\/p>\n<p>sudo apt install python2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8bf7\u6ce8\u610f\uff0c\u67d0\u4e9b\u73b0\u4ee3\u7248\u672c\u7684Ubuntu\u53ef\u80fd\u9ed8\u8ba4\u4e0d\u518d\u5305\u542bPython 2\uff0c\u53ef\u80fd\u9700\u8981\u989d\u5916\u6dfb\u52a0\u65e7\u7248\u672c\u8f6f\u4ef6\u6e90\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528\u7b2c\u4e09\u65b9\u955c\u50cf\u4e0b\u8f7d<\/p>\n<\/p>\n<p><p>\u5982\u679c\u5b98\u7f51\u4e0b\u8f7d\u901f\u5ea6\u8f83\u6162\u6216\u9047\u5230\u5176\u4ed6\u95ee\u9898\uff0c\u53ef\u4ee5\u901a\u8fc7\u7b2c\u4e09\u65b9\u955c\u50cf\u7ad9\u4e0b\u8f7dPython 2\u3002\u4f46\u52a1\u5fc5\u9009\u62e9\u53d7\u4fe1\u4efb\u7684\u955c\u50cf\u6e90\uff0c\u4ee5\u907f\u514d\u6076\u610f\u8f6f\u4ef6\u548c\u5b89\u5168\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u955c\u50cf\u7ad9<\/strong><br \/>\u5728\u5168\u7403\u5404\u5730\u90fd\u6709\u8bb8\u591aPython\u955c\u50cf\u7ad9\uff0c\u4f8b\u5982\u6e05\u534e\u5927\u5b66\u5f00\u6e90\u8f6f\u4ef6\u955c\u50cf\u7ad9\u3001\u963f\u91cc\u4e91\u5f00\u6e90\u955c\u50cf\u7ad9\u7b49\u3002\u8fd9\u4e9b\u955c\u50cf\u7ad9\u901a\u5e38\u4f1a\u63d0\u4f9b\u4e0e\u5b98\u7f51\u4e00\u81f4\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7d\u548c\u5b89\u88c5<\/strong><br \/>\u8bbf\u95ee\u955c\u50cf\u7ad9\uff0c\u627e\u5230Python 2.7.x\u7248\u672c\u7684\u4e0b\u8f7d\u94fe\u63a5\uff0c\u9009\u62e9\u5408\u9002\u7684\u5b89\u88c5\u5305\u8fdb\u884c\u4e0b\u8f7d\u548c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u548c\u4f7f\u7528Python 2\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u5168\u6027<\/strong><br \/>\u7531\u4e8ePython 2\u4e0d\u518d\u53d7\u5230\u5b98\u65b9\u652f\u6301\uff0c\u4f7f\u7528\u5b83\u53ef\u80fd\u5b58\u5728\u5b89\u5168\u98ce\u9669\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u4ec5\u5728\u5b66\u4e60\u3001\u7ef4\u62a4\u65e7\u7cfb\u7edf\u6216\u7279\u5b9a\u5f00\u53d1\u9700\u6c42\u65f6\u4f7f\u7528Python 2\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u517c\u5bb9\u6027<\/strong><br \/>Python 3\u548cPython 2\u5728\u8bed\u6cd5\u548c\u529f\u80fd\u4e0a\u5b58\u5728\u4e0d\u517c\u5bb9\u4e4b\u5904\u3002\u5982\u679c\u60a8\u7684<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/59535.html\" target=\"_blank\">\u9879\u76ee\u8ba1\u5212<\/a>\u672a\u6765\u8fc1\u79fb\u5230Python 3\uff0c\u5efa\u8bae\u5c3d\u65e9\u8fdb\u884c\u517c\u5bb9\u6027\u6d4b\u8bd5\u548c\u8c03\u6574\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u865a\u62df\u73af\u5883<\/strong><br \/>\u5982\u679c\u5728\u540c\u4e00\u7cfb\u7edf\u4e0a\u9700\u8981\u540c\u65f6\u4f7f\u7528Python 2\u548cPython 3\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u865a\u62df\u73af\u5883\u5de5\u5177\uff08\u5982virtualenv\uff09\u6765\u9694\u79bb\u4e0d\u540c\u7248\u672c\u7684Python\u73af\u5883\uff0c\u907f\u514d\u51b2\u7a81\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fc1\u79fb\u8ba1\u5212<\/strong><br \/>\u5982\u679c\u6b63\u5728\u7ef4\u62a4\u4f7f\u7528Python 2\u7684\u9879\u76ee\uff0c\u5efa\u8bae\u5236\u5b9a\u8fc1\u79fb\u8ba1\u5212\uff0c\u9010\u6b65\u5c06\u4ee3\u7801\u8f6c\u6362\u4e3aPython 3\uff0c\u4ee5\u4fbf\u5229\u7528\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u66f4\u65b0\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5728\u9700\u8981\u65f6\u987a\u5229\u4e0b\u8f7d\u548c\u5b89\u88c5Python 2\uff0c\u4f46\u52a1\u5fc5\u6ce8\u610f\u5b89\u5168\u548c\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728\u54ea\u91cc\u53ef\u4ee5\u627e\u5230Python 2\u7684\u4e0b\u8f7d\u94fe\u63a5\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u5728Python\u5b98\u65b9\u7f51\u7ad9\u7684\u65e7\u7248\u672c\u9875\u9762\u627e\u5230Python 2\u7684\u4e0b\u8f7d\u94fe\u63a5\u3002\u8bbf\u95ee<a href=\"https:\/\/www.python.org\/downloads\/release\/python-2718\/\">Python.org<\/a>\u540e\uff0c\u9009\u62e9\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002<\/p>\n<p><strong>Python 2\u7684\u7cfb\u7edf\u8981\u6c42\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>Python 2\u7684\u7cfb\u7edf\u8981\u6c42\u56e0\u7248\u672c\u800c\u5f02\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u60a8\u53ef\u4ee5\u5728Windows\u3001macOS\u548cLinux\u7b49\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5Python 2\u3002\u5efa\u8bae\u68c0\u67e5\u5177\u4f53\u7248\u672c\u7684\u6587\u6863\uff0c\u4ee5\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u6ee1\u8db3\u5b89\u88c5\u8981\u6c42\u3002<\/p>\n<p><strong>\u5b89\u88c5Python 2\u540e\uff0c\u6211\u5982\u4f55\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python2 --version<\/code>\u3002\u5982\u679c\u663e\u793aPython 2\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002\u5982\u679c\u672a\u80fd\u663e\u793a\uff0c\u53ef\u80fd\u9700\u8981\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6216\u91cd\u65b0\u5b89\u88c5\u3002<\/p>\n<p><strong>Python 2\u662f\u5426\u8fd8\u4f1a\u63a5\u6536\u66f4\u65b0\u6216\u652f\u6301\uff1f<\/strong><br \/>Python 2\u57282020\u5e741\u67081\u65e5\u505c\u6b62\u4e86\u5b98\u65b9\u652f\u6301\uff0c\u8fd9\u610f\u5473\u7740\u5c06\u4e0d\u518d\u6709\u5b89\u5168\u66f4\u65b0\u6216bug\u4fee\u590d\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u7528\u6237\u5c3d\u53ef\u80fd\u8fc1\u79fb\u5230Python 3\uff0c\u4ee5\u83b7\u5f97\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u6027\u3002<\/p>\n<p><strong>\u6211\u80fd\u5426\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u540c\u65f6\u5b89\u88c5Python 2\u548cPython 3\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u60a8\u53ef\u4ee5\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u5b89\u88c5Python 2\u548cPython 3\u3002\u4e3a\u4e86\u907f\u514d\u51b2\u7a81\uff0c\u5efa\u8bae\u5728\u5b89\u88c5\u65f6\u4f7f\u7528\u4e0d\u540c\u7684\u547d\u4ee4\u6765\u8c03\u7528\u5b83\u4eec\uff0c\u4f8b\u5982\u4f7f\u7528<code>python2<\/code>\u548c<code>python3<\/code>\u3002\u786e\u4fdd\u6839\u636e\u9700\u8981\u8bbe\u7f6e\u597d\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u6b63\u786e\u8fd0\u884c\u4e24\u4e2a\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u4e0b\u8f7dPython 2\uff0c\u9996\u5148\u9700\u8981\u660e\u786ePython 2\u5df2\u7ecf\u505c\u6b62\u5b98\u65b9\u652f\u6301\uff0c\u56e0\u6b64\u4e0d\u5efa\u8bae\u5728\u65b0\u9879\u76ee\u4e2d\u4f7f\u7528\u5b83\u3002\u4e0d\u8fc7\uff0c\u5982\u679c\u60a8 [&hellip;]","protected":false},"author":3,"featured_media":984136,"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\/984124"}],"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=984124"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/984124\/revisions"}],"predecessor-version":[{"id":984138,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/984124\/revisions\/984138"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/984136"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=984124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=984124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=984124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}