{"id":1030699,"date":"2024-12-31T11:19:18","date_gmt":"2024-12-31T03:19:18","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1030699.html"},"modified":"2024-12-31T11:19:21","modified_gmt":"2024-12-31T03:19:21","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8linux%e4%b8%8a%e9%87%8d%e8%a3%85python2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1030699.html","title":{"rendered":"\u5982\u4f55\u5728Linux\u4e0a\u91cd\u88c5Python2"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/5505a6d4-3382-42a4-b4fd-04ae3866dd2e.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u5728Linux\u4e0a\u91cd\u88c5Python2\" \/><\/p>\n<p><p> <strong>\u5728Linux\u4e0a\u91cd\u88c5Python2\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u91cd\u65b0\u5b89\u88c5\u3001\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406Python\u7248\u672c\u3002<\/strong> \u5176\u4e2d\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u91cd\u65b0\u5b89\u88c5\u662f\u6700\u4fbf\u6377\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u7b80\u5316\u4e86\u8bb8\u591a\u590d\u6742\u7684\u6b65\u9aa4\uff0c\u5e76\u4e14\u53ef\u4ee5\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\u3002\u5305\u7ba1\u7406\u5668\u5982apt\u3001yum\u7b49\u90fd\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u91cd\u65b0\u5b89\u88c5Python2<\/h3>\n<\/p>\n<p><p>\u5305\u7ba1\u7406\u5668\u662fLinux\u7cfb\u7edf\u4e2d\u7528\u4e8e\u7ba1\u7406\u8f6f\u4ef6\u5305\u7684\u5de5\u5177\u3002\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u6709\u4e0d\u540c\u7684\u5305\u7ba1\u7406\u5668\uff0c\u5982Debian\u7cfb\u7684apt\u548cRedHat\u7cfb\u7684yum\u3002\u4ee5\u4e0b\u5206\u522b\u4ecb\u7ecd\u5728\u4e0d\u540c\u5305\u7ba1\u7406\u5668\u4e0b\u5982\u4f55\u91cd\u65b0\u5b89\u88c5Python2\u3002<\/p>\n<\/p>\n<p><h4>1.1\u3001\u4f7f\u7528apt\u5305\u7ba1\u7406\u5668<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u57fa\u4e8eDebian\u7684\u7cfb\u7edf\uff0c\u5982Ubuntu\uff0c\u53ef\u4ee5\u4f7f\u7528apt-get\u547d\u4ee4\u6765\u91cd\u65b0\u5b89\u88c5Python2\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get update<\/p>\n<p>sudo apt-get install --reinstall python2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u9996\u5148\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff0c\u7136\u540e\u91cd\u65b0\u5b89\u88c5Python2\u3002<strong>apt-get install &#8211;reinstall<\/strong>\u547d\u4ee4\u5c06\u5f3a\u5236\u91cd\u65b0\u5b89\u88c5\u6307\u5b9a\u7684\u8f6f\u4ef6\u5305\uff0c\u5373\u4f7f\u5b83\u5df2\u7ecf\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h4>1.2\u3001\u4f7f\u7528yum\u5305\u7ba1\u7406\u5668<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u57fa\u4e8eRedHat\u7684\u7cfb\u7edf\uff0c\u5982CentOS\uff0c\u53ef\u4ee5\u4f7f\u7528yum\u547d\u4ee4\u6765\u91cd\u65b0\u5b89\u88c5Python2\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum reinstall python2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u540c\u6837\uff0c<strong>yum reinstall<\/strong>\u547d\u4ee4\u5c06\u91cd\u65b0\u5b89\u88c5\u6307\u5b9a\u7684\u8f6f\u4ef6\u5305\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5Python2<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u5305\u7ba1\u7406\u5668\u65e0\u6cd5\u6ee1\u8db3\u9700\u6c42\uff0c\u6216\u8005\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684Python2\uff0c\u53ef\u4ee5\u9009\u62e9\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u6240\u6709\u7684Linux\u53d1\u884c\u7248\u3002<\/p>\n<\/p>\n<p><h4>2.1\u3001\u4e0b\u8f7d\u6e90\u7801<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4e0b\u8f7dPython2\u7684\u6e90\u7801\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u83b7\u53d6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">wget https:\/\/www.python.org\/ftp\/python\/2.x.x\/Python-2.x.x.tgz<\/p>\n<p>tar -xvf Python-2.x.x.tgz<\/p>\n<p>cd Python-2.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8bf7\u5c06\u4e0a\u9762\u76842.x.x\u66ff\u6362\u4e3a\u5177\u4f53\u7684Python2\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><h4>2.2\u3001\u7f16\u8bd1\u548c\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u914d\u7f6e\u7f16\u8bd1\u73af\u5883\u5e76\u5b89\u88c5Python2\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/configure --prefix=\/usr\/local\/python2<\/p>\n<p>make<\/p>\n<p>sudo make install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>.\/configure<\/strong>\u547d\u4ee4\u7528\u4e8e\u914d\u7f6e\u7f16\u8bd1\u73af\u5883\uff0c<strong>make<\/strong>\u547d\u4ee4\u7528\u4e8e\u7f16\u8bd1\u6e90\u4ee3\u7801\uff0c<strong>sudo make install<\/strong>\u547d\u4ee4\u7528\u4e8e\u5b89\u88c5\u7f16\u8bd1\u540e\u7684\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406Python\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5728\u4e0d\u5f71\u54cd\u7cfb\u7edf\u9ed8\u8ba4Python\u7248\u672c\u7684\u60c5\u51b5\u4e0b\u7ba1\u7406\u4e0d\u540c\u7684Python\u7248\u672c\u3002<strong>virtualenv<\/strong>\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u865a\u62df\u73af\u5883\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h4>3.1\u3001\u5b89\u88c5virtualenv<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5virtualenv\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python-virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff0c\u5bf9\u4e8e\u57fa\u4e8eRedHat\u7684\u7cfb\u7edf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install python-virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2\u3001\u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528virtualenv\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python2\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">virtualenv -p \/usr\/bin\/python2 myenv<\/p>\n<p>source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>virtualenv -p<\/strong>\u547d\u4ee4\u6307\u5b9aPython\u89e3\u91ca\u5668\uff0c<strong>source myenv\/bin\/activate<\/strong>\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u53ef\u4ee5\u5b89\u88c5\u548c\u4f7f\u7528\u4efb\u4f55\u9700\u8981\u7684Python2\u7248\u672c\u5e93\u800c\u4e0d\u5f71\u54cd\u7cfb\u7edf\u5168\u5c40\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u89e3\u51b3\u4f9d\u8d56\u95ee\u9898<\/h3>\n<\/p>\n<p><p>\u5728\u91cd\u65b0\u5b89\u88c5Python2\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4f9d\u8d56\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u4f9d\u8d56\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h4>4.1\u3001\u7f3a\u5c11\u5f00\u53d1\u5de5\u5177<\/h4>\n<\/p>\n<p><p>\u7f16\u8bd1Python2\u6e90\u7801\u65f6\uff0c\u53ef\u80fd\u4f1a\u7f3a\u5c11\u4e00\u4e9b\u5f00\u53d1\u5de5\u5177\uff0c\u5982gcc\u3001make\u7b49\u3002\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u8fd9\u4e9b\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install build-essential<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff0c\u5bf9\u4e8e\u57fa\u4e8eRedHat\u7684\u7cfb\u7edf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum groupinstall &quot;Development Tools&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2\u3001\u7f3a\u5c11\u5e93\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u7f16\u8bd1Python2\u6e90\u7801\u65f6\uff0c\u53ef\u80fd\u4f1a\u7f3a\u5c11\u4e00\u4e9b\u5e93\u6587\u4ef6\uff0c\u5982zlib\u3001openssl\u7b49\u3002\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u8fd9\u4e9b\u5e93\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install zlib1g-dev libssl-dev<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff0c\u5bf9\u4e8e\u57fa\u4e8eRedHat\u7684\u7cfb\u7edf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install zlib-devel openssl-devel<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6d4b\u8bd5\u5b89\u88c5\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u91cd\u65b0\u5b89\u88c5Python2\u540e\uff0c\u9700\u8981\u9a8c\u8bc1\u5b89\u88c5\u7ed3\u679c\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bPython\u7248\u672c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python2 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python2\u7248\u672c\u53f7\u3002\u5982\u679c\u663e\u793a\u6b63\u786e\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython2\u5df2\u7ecf\u6210\u529f\u91cd\u65b0\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5Python2\uff0c\u9700\u8981\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u7cfb\u7edf\u80fd\u591f\u627e\u5230Python2\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>6.1\u3001\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo nano \/etc\/profile<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>6.2\u3001\u6dfb\u52a0\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=\/usr\/local\/python2\/bin:$PATH<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f7f\u73af\u5883\u53d8\u91cf\u751f\u6548\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source \/etc\/profile<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u5b89\u88c5\u5e38\u7528Python\u5e93<\/h3>\n<\/p>\n<p><p>\u91cd\u65b0\u5b89\u88c5Python2\u540e\uff0c\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u5e38\u7528\u7684Python\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\u6765\u5b89\u88c5\u8fd9\u4e9b\u5e93\u3002<\/p>\n<\/p>\n<p><h4>7.1\u3001\u5b89\u88c5pip<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5pip\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff0c\u5bf9\u4e8e\u57fa\u4e8eRedHat\u7684\u7cfb\u7edf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install python-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>7.2\u3001\u5b89\u88c5\u5e38\u7528\u5e93<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528pip\u5de5\u5177\u5b89\u88c5\u5e38\u7528\u7684Python\u5e93\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy pandas matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u5b89\u88c5numpy\u3001pandas\u548cmatplotlib\u7b49\u5e38\u7528\u7684Python\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u91cd\u65b0\u5b89\u88c5Python2\u5728Linux\u7cfb\u7edf\u4e2d\u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u91cd\u65b0\u5b89\u88c5\u3001\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u6216\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u4e0d\u540c\u7684Python\u7248\u672c\u3002\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u91cd\u65b0\u5b89\u88c5\u662f\u6700\u4fbf\u6377\u7684\u65b9\u6cd5\uff0c\u800c\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u53ef\u4ee5\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5728\u4e0d\u5f71\u54cd\u7cfb\u7edf\u9ed8\u8ba4Python\u7248\u672c\u7684\u60c5\u51b5\u4e0b\u7ba1\u7406\u4e0d\u540c\u7684Python\u7248\u672c\u3002\u5728\u91cd\u65b0\u5b89\u88c5Python2\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4f9d\u8d56\u95ee\u9898\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u7f3a\u5c11\u7684\u5f00\u53d1\u5de5\u5177\u548c\u5e93\u6587\u4ef6\u6765\u89e3\u51b3\u3002\u91cd\u65b0\u5b89\u88c5Python2\u540e\uff0c\u9700\u8981\u9a8c\u8bc1\u5b89\u88c5\u7ed3\u679c\uff0c\u5e76\u6839\u636e\u9700\u8981\u5b89\u88c5\u5e38\u7528\u7684Python\u5e93\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Linux\u4e0a\u91cd\u88c5Python2\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u6b65\u9aa4\uff1f<\/strong><br \/>\u91cd\u88c5Python2\u7684\u8fc7\u7a0b\u76f8\u5bf9\u7b80\u5355\uff0c\u4f46\u9700\u8981\u786e\u4fdd\u5728\u6b63\u786e\u7684\u73af\u5883\u4e0b\u8fdb\u884c\u3002\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u4f7f\u7528\u9002\u5408\u60a8\u7684Linux\u53d1\u884c\u7248\u7684\u5305\u7ba1\u7406\u5668\uff08\u5982apt\u3001yum\u6216dnf\uff09\u6765\u5378\u8f7d\u73b0\u6709\u7684Python2\u7248\u672c\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u91cd\u65b0\u5b89\u88c5Python2\uff0c\u786e\u4fdd\u5b89\u88c5\u8fc7\u7a0b\u6ca1\u6709\u9519\u8bef\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>python2 --version<\/code>\u6765\u786e\u8ba4\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p><strong>\u5728\u91cd\u88c5Python2\u65f6\u9700\u8981\u5907\u4efd\u54ea\u4e9b\u6587\u4ef6\u6216\u8bbe\u7f6e\uff1f<\/strong><br \/>\u5728\u91cd\u88c5Python2\u4e4b\u524d\uff0c\u5efa\u8bae\u5907\u4efd\u4f7f\u7528Python2\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u548c\u91cd\u8981\u7684\u9879\u76ee\u6587\u4ef6\u3002\u5982\u679c\u60a8\u5728\u4f7f\u7528Python2\u65f6\u5b89\u88c5\u4e86\u7279\u5b9a\u7684\u5e93\u6216\u5305\uff0c\u8bb0\u5f97\u8bb0\u5f55\u4e0b\u6765\uff0c\u65b9\u4fbf\u5728\u91cd\u88c5\u540e\u91cd\u65b0\u5b89\u88c5\u3002\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<code>pip freeze &gt; requirements.txt<\/code>\u547d\u4ee4\u751f\u6210\u4f9d\u8d56\u6587\u4ef6\uff0c\u4ee5\u4fbf\u6062\u590d\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u5728Linux\u4e0a\u540c\u65f6\u5b89\u88c5Python2\u548cPython3\uff1f<\/strong><br \/>\u5b8c\u5168\u53ef\u4ee5\u5728Linux\u4e0a\u540c\u65f6\u5b89\u88c5Python2\u548cPython3\u3002\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u4f1a\u5c06Python2\u548cPython3\u5206\u522b\u5b89\u88c5\u5728\u4e0d\u540c\u7684\u8def\u5f84\u4e0b\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>python2<\/code>\u548c<code>python3<\/code>\u6765\u5206\u522b\u8c03\u7528\u5b83\u4eec\u3002\u4e3a\u4e86\u907f\u514d\u8def\u5f84\u51b2\u7a81\uff0c\u5efa\u8bae\u5728\u4f7f\u7528\u65f6\u660e\u786e\u6307\u5b9a\u7248\u672c\uff0c\u5c24\u5176\u662f\u5728\u8fd0\u884c\u811a\u672c\u65f6\uff0c\u53ef\u4ee5\u5728\u811a\u672c\u5f00\u5934\u6dfb\u52a0<code>#!\/usr\/bin\/env python2<\/code>\u6216<code>#!\/usr\/bin\/env python3<\/code>\u6765\u6307\u5b9a\u4f7f\u7528\u7684Python\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u4e0a\u91cd\u88c5Python2\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u91cd\u65b0\u5b89\u88c5\u3001\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406Python [&hellip;]","protected":false},"author":3,"featured_media":1030712,"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\/1030699"}],"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=1030699"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1030699\/revisions"}],"predecessor-version":[{"id":1030713,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1030699\/revisions\/1030713"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1030712"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1030699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1030699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1030699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}