{"id":1010760,"date":"2024-12-27T11:24:06","date_gmt":"2024-12-27T03:24:06","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1010760.html"},"modified":"2024-12-27T11:24:08","modified_gmt":"2024-12-27T03:24:08","slug":"%e5%a6%82%e4%bd%95%e5%8d%87%e7%ba%a7python-2-7-6-2-7-9","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1010760.html","title":{"rendered":"\u5982\u4f55\u5347\u7ea7python 2.7.6 2.7.9"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25085154\/217829f3-196c-44c7-a165-bd55f7192d12.webp\" alt=\"\u5982\u4f55\u5347\u7ea7python 2.7.6 2.7.9\" \/><\/p>\n<p><p> <strong>\u8981\u5c06 Python 2.7.6 \u5347\u7ea7\u5230 2.7.9\uff0c\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u5b89\u88c5\u65b0\u7248\u672c\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982 Homebrew \u6216 apt-get\uff09\u3001\u7f16\u8bd1\u6e90\u4ee3\u7801\u7b49\u65b9\u6cd5\u3002<\/strong> \u5176\u4e2d\uff0c<strong>\u91cd\u65b0\u5b89\u88c5\u65b0\u7248\u672c<\/strong>\u7684\u65b9\u6cd5\u76f8\u5bf9\u7b80\u5355\u4e14\u9002\u7528\u4e8e\u5927\u591a\u6570\u7cfb\u7edf\uff0c\u56e0\u6b64\u5728\u8fd9\u91cc\u5c06\u8be6\u7ec6\u5c55\u5f00\u8fd9\u4e00\u70b9\u3002<\/p>\n<\/p>\n<p><p>\u91cd\u65b0\u5b89\u88c5\u65b0\u7248\u672c\u662f\u901a\u8fc7\u4e0b\u8f7d Python 2.7.9 \u7684\u5b89\u88c5\u5305\uff0c\u5e76\u5728\u7cfb\u7edf\u4e2d\u5378\u8f7d\u65e7\u7248\u672c\u540e\u91cd\u65b0\u5b89\u88c5\u65b0\u7248\u672c\u3002\u6b64\u65b9\u6cd5\u9002\u7528\u4e8e\u5927\u591a\u6570\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5982 Windows\u3001macOS \u548c Linux\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e0b\u8f7d Python 2.7.9<\/h3>\n<\/p>\n<ol>\n<li><strong>\u8bbf\u95ee\u5b98\u65b9\u7f51\u7ad9<\/strong>\uff1a\u9996\u5148\uff0c\u524d\u5f80 Python \u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%9C%A8%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E4%B8%AD%E6%89%BE%E5%88%B0%E9%80%82%E7%94%A8%E4%BA%8E%E6%82%A8%E7%B3%BB%E7%BB%9F%E7%9A%84\">https:\/\/www.python.org\/\uff09\uff0c\u5728\u4e0b\u8f7d\u9875\u9762\u4e2d\u627e\u5230\u9002\u7528\u4e8e\u60a8\u7cfb\u7edf\u7684<\/a> Python 2.7.9 \u5b89\u88c5\u5305\u3002<\/li>\n<li><strong>\u9009\u62e9\u6b63\u786e\u7684\u7248\u672c<\/strong>\uff1a\u6839\u636e\u60a8\u4f7f\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\uff08Windows\u3001macOS\u3001Linux\uff09\u9009\u62e9\u76f8\u5e94\u7684\u5b89\u88c5\u5305\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f Windows\uff0c\u60a8\u8fd8\u9700\u8981\u6839\u636e\u7cfb\u7edf\u67b6\u6784\u9009\u62e9 32 \u4f4d\u6216 64 \u4f4d\u7684\u5b89\u88c5\u5305\u3002<\/li>\n<li><strong>\u4e0b\u8f7d\u5b89\u88c5\u5305<\/strong>\uff1a\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\uff0c\u5c06\u5b89\u88c5\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u5378\u8f7d Python 2.7.6<\/h3>\n<\/p>\n<ol>\n<li><strong>Windows<\/strong>\uff1a\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\uff0c\u8fdb\u5165\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\uff0c\u627e\u5230 Python 2.7.6\uff0c\u53f3\u952e\u9009\u62e9\u201c\u5378\u8f7d\u201d\u3002<\/li>\n<li><strong>macOS<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c <code>brew uninstall python<\/code> \u7684\u547d\u4ee4\uff08\u5982\u679c\u4f7f\u7528\u4e86 Homebrew \u5b89\u88c5\uff09\uff0c\u6216\u8005\u624b\u52a8\u5220\u9664 <code>\/Library\/Frameworks\/Python.framework\/Versions\/2.7<\/code> \u76ee\u5f55\u3002<\/li>\n<li><strong>Linux<\/strong>\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5378\u8f7d\uff0c\u6bd4\u5982 <code>sudo apt-get remove python2.7<\/code>\uff08\u6ce8\u610f\uff1a\u8fd9\u53ef\u80fd\u4f1a\u5f71\u54cd\u4f9d\u8d56 Python 2.7 \u7684\u5176\u4ed6\u8f6f\u4ef6\u5305\uff09\u3002<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u5b89\u88c5 Python 2.7.9<\/h3>\n<\/p>\n<ol>\n<li><strong>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f<\/strong>\uff1a\u53cc\u51fb\u60a8\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff0c\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<li><strong>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\uff1a\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u6dfb\u52a0 Python \u5230\u7cfb\u7edf PATH \u7684\u9009\u9879\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528 Python \u547d\u4ee4\u3002<\/li>\n<li><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165 <code>python --version<\/code>\uff0c\u786e\u8ba4\u663e\u793a\u4e3a Python 2.7.9\u3002<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5347\u7ea7<\/h3>\n<\/p>\n<p><h4>Windows<\/h4>\n<\/p>\n<p><p>\u5728 Windows \u4e0a\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982 Chocolatey\uff09\u53ef\u4ee5\u7b80\u5316 Python \u7684\u5b89\u88c5\u548c\u5347\u7ea7\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5 Chocolatey<\/strong>\uff1a\u6253\u5f00 PowerShell\uff0c\u5e76\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Chocolatey\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-powershell\">Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(&#39;https:\/\/chocolatey.org\/install.ps1&#39;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5347\u7ea7 Python<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528 Chocolatey \u5347\u7ea7 Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-powershell\">choco upgrade python --version=2.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>macOS<\/h4>\n<\/p>\n<p><p>\u5728 macOS \u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528 Homebrew \u8fdb\u884c\u5347\u7ea7\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u66f4\u65b0 Homebrew<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0 Homebrew\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684 Python<\/strong>\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Python 2.7.9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python@2.7.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>Linux<\/h4>\n<\/p>\n<p><p>\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982 apt-get \u6216 yum\uff09\u4e5f\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406 Python\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868<\/strong>\uff1a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684 Python<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Python 2.7.9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python2.7=2.7.9-1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u7f16\u8bd1\u6e90\u4ee3\u7801\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u67d0\u4e9b\u73af\u5883\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1 Python\uff0c\u4ee5\u786e\u4fdd\u5b8c\u5168\u7684\u81ea\u5b9a\u4e49\u6216\u517c\u5bb9\u6027\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7d\u6e90\u4ee3\u7801<\/strong>\uff1a\u4ece Python \u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d Python 2.7.9 \u7684\u6e90\u4ee3\u7801\u538b\u7f29\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u538b\u7f29\u6587\u4ef6<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\uff0c\u4f7f\u7528 <code>tar<\/code> \u547d\u4ee4\u89e3\u538b\u7f29\u4e0b\u8f7d\u7684\u538b\u7f29\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">tar -xvf Python-2.7.9.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u7f16\u8bd1\u73af\u5883<\/strong>\uff1a\u8fdb\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e\u7f16\u8bd1\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd Python-2.7.9<\/p>\n<p>.\/configure<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8bd1\u5e76\u5b89\u88c5<\/strong>\uff1a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1\u5e76\u5b89\u88c5 Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">make<\/p>\n<p>sudo make install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u8f93\u5165 <code>python --version<\/code> \u786e\u8ba4\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<ol>\n<li><strong>\u5907\u4efd\u6570\u636e<\/strong>\uff1a\u5728\u5347\u7ea7 Python \u524d\uff0c\u5efa\u8bae\u5907\u4efd\u53ef\u80fd\u53d7\u5f71\u54cd\u7684\u9879\u76ee\u6216\u73af\u5883\u3002<\/li>\n<li><strong>\u4f9d\u8d56\u7ba1\u7406<\/strong>\uff1a\u6ce8\u610f\u9879\u76ee\u4e2d\u7684\u4f9d\u8d56\u5305\u662f\u5426\u4e0e\u65b0\u7248\u672c\u517c\u5bb9\uff0c\u53ef\u80fd\u9700\u8981\u5728\u5347\u7ea7\u540e\u91cd\u65b0\u5b89\u88c5\u6216\u66f4\u65b0\u8fd9\u4e9b\u5305\u3002<\/li>\n<li><strong>\u5b89\u5168\u6027<\/strong>\uff1aPython 2.7 \u5df2\u7ecf\u505c\u6b62\u7ef4\u62a4\uff0c\u5efa\u8bae\u5c3d\u91cf\u8fc1\u79fb\u5230 Python 3.x \u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u5b89\u5168\u6027\u548c\u65b0\u7279\u6027\u652f\u6301\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u6210\u529f\u5c06 Python \u4ece 2.7.6 \u5347\u7ea7\u5230 2.7.9\uff0c\u540c\u65f6\u4e5f\u638c\u63e1\u4e86\u901a\u8fc7\u4e0d\u540c\u65b9\u6cd5\u8fdb\u884c Python \u5347\u7ea7\u7684\u6280\u5de7\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u6211\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u8981\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python -V<\/code>\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fPython 2.x\uff0c\u8f93\u51fa\u4f1a\u663e\u793a\u7c7b\u4f3c\u4e8e\u201cPython 2.7.6\u201d\u7684\u4fe1\u606f\u3002\u786e\u4fdd\u5728\u5347\u7ea7\u4e4b\u524d\u786e\u8ba4\u7248\u672c\u53f7\uff0c\u4ee5\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u6df7\u6dc6\u3002<\/p>\n<p><strong>\u5728Windows\u7cfb\u7edf\u4e0a\u5982\u4f55\u8fdb\u884cPython\u7248\u672c\u5347\u7ea7\uff1f<\/strong><br \/>\u5728Windows\u4e0a\uff0c\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8e2.7.9\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5e76\u786e\u4fdd\u9009\u62e9\u201cUpgrade Now\u201d\u9009\u9879\u3002\u8fd9\u5c06\u4f1a\u5c06\u60a8\u7684Python 2.7.6\u7248\u672c\u76f4\u63a5\u5347\u7ea7\u52302.7.9\u7248\u672c\u3002\u5b89\u88c5\u8fc7\u7a0b\u7ed3\u675f\u540e\uff0c\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528<code>python --version<\/code>\u547d\u4ee4\u786e\u8ba4\u5347\u7ea7\u6210\u529f\u3002<\/p>\n<p><strong>\u5728Linux\u6216macOS\u4e0a\u5982\u4f55\u4f7f\u7528\u547d\u4ee4\u884c\u5347\u7ea7Python\uff1f<\/strong><br \/>\u5728Linux\u6216macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u5347\u7ea7Python\u7248\u672c\u3002\u5bf9\u4e8eDebian\u6216Ubuntu\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<code>sudo apt-get install python2.7=2.7.9-1<\/code>\u6765\u6307\u5b9a\u7248\u672c\u8fdb\u884c\u5b89\u88c5\u3002\u5bf9\u4e8emacOS\u7528\u6237\uff0c\u5982\u679c\u60a8\u4f7f\u7528Homebrew\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>brew upgrade python@2<\/code>\u6765\u5347\u7ea7\u5230\u6700\u65b0\u7684Python 2\u7248\u672c\u3002\u786e\u4fdd\u5728\u5347\u7ea7\u4e4b\u524d\u5907\u4efd\u60a8\u7684\u9879\u76ee\uff0c\u4ee5\u9632\u4e07\u4e00\u51fa\u73b0\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5c06 Python 2.7.6 \u5347\u7ea7\u5230 2.7.9\uff0c\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u5b89\u88c5\u65b0\u7248\u672c\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982 Homebrew [&hellip;]","protected":false},"author":3,"featured_media":1010767,"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\/1010760"}],"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=1010760"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1010760\/revisions"}],"predecessor-version":[{"id":1010771,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1010760\/revisions\/1010771"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1010767"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1010760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1010760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1010760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}