{"id":43934,"date":"2024-10-06T11:37:12","date_gmt":"2024-10-06T03:37:12","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43934\/"},"modified":"2024-10-06T11:37:12","modified_gmt":"2024-10-06T03:37:12","slug":"centos-7-%e4%b8%ad%e5%b0%87-python-2-7-5-%e5%8d%87%e7%b4%9a%e5%88%b0-python-3-5-2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43934\/","title":{"rendered":"CentOS 7 \u4e2d\u5c07 Python 2.7.5 \u5347\u7d1a\u5230 Python 3.5.2"},"content":{"rendered":"<h1 id=\"centos-7-%e4%b8%ad%e5%b0%87-python-2-7-5-%e5%8d%87%e7%b4%9a%e5%88%b0-python-3-5-2-RwLSuGIFEB\">CentOS 7 \u4e2d\u5c07 Python 2.7.5 \u5347\u7d1a\u5230 Python 3.5.2<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u958b\u767c\u74b0\u5883\u4e2d\uff0cPython \u662f\u4e00\u7a2e\u5ee3\u6cdb\u4f7f\u7528\u7684\u7de8\u7a0b\u8a9e\u8a00\u3002\u96a8\u8457 Python 2 \u7684\u5b98\u65b9\u652f\u6301\u65bc 2020 \u5e74 1 \u6708\u7d50\u675f\uff0c\u8a31\u591a\u7528\u6236\u9078\u64c7\u5c07\u5176\u5347\u7d1a\u5230 Python 3\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u7cfb\u7d71\u4e2d\u5c07 Python 2.7.5 \u5347\u7d1a\u5230 Python 3.5.2\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%81%b8%e6%93%87-python-3%ef%bc%9f-RwLSuGIFEB\">\u70ba\u4ec0\u9ebc\u9078\u64c7 Python 3\uff1f<\/h2>\n<p>Python 3 \u63d0\u4f9b\u4e86\u8a31\u591a\u65b0\u7279\u6027\u548c\u6539\u9032\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u66f4\u597d\u7684 Unicode \u652f\u6301\uff0c\u80fd\u5920\u8655\u7406\u591a\u7a2e\u8a9e\u8a00\u7684\u5b57\u7b26\u3002<\/li>\n<li>\u8a9e\u6cd5\u7684\u7c21\u5316\uff0c\u4f7f\u5f97\u4ee3\u78bc\u66f4\u6613\u65bc\u95b1\u8b80\u548c\u7dad\u8b77\u3002<\/li>\n<li>\u8a31\u591a\u6a19\u6e96\u5eab\u7684\u6539\u9032\uff0c\u63d0\u4f9b\u4e86\u66f4\u5f37\u5927\u7684\u529f\u80fd\u3002<\/li>\n<\/ul>\n<p>\u56e0\u6b64\uff0c\u5347\u7d1a\u5230 Python 3 \u662f\u4e00\u500b\u660e\u667a\u7684\u9078\u64c7\uff0c\u7279\u5225\u662f\u5c0d\u65bc\u65b0\u9805\u76ee\u548c\u6301\u7e8c\u7684\u958b\u767c\u5de5\u4f5c\u3002<\/p>\n<h2 id=\"%e5%8d%87%e7%b4%9a%e6%ad%a5%e9%a9%9f-RwLSuGIFEB\">\u5347\u7d1a\u6b65\u9a5f<\/h2>\n<p>\u4ee5\u4e0b\u662f\u5c07 CentOS 7 \u4e2d\u7684 Python 2.7.5 \u5347\u7d1a\u5230 Python 3.5.2 \u7684\u5177\u9ad4\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e5%ae%89%e8%a3%9d-epel-%e5%ad%98%e5%84%b2%e5%ba%ab-RwLSuGIFEB\">1. \u5b89\u88dd EPEL \u5b58\u5132\u5eab<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88dd EPEL\uff08Extra Packages for Enterprise Linux\uff09\u5b58\u5132\u5eab\uff0c\u56e0\u70ba Python 3.5.2 \u53ef\u80fd\u4e0d\u5728\u9ed8\u8a8d\u7684 CentOS \u5b58\u5132\u5eab\u4e2d\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd EPEL\uff1a<\/p>\n<pre><code>sudo yum install epel-release<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-python-3-5-2-RwLSuGIFEB\">2. \u5b89\u88dd Python 3.5.2<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Python 3.5.2\uff1a<\/p>\n<pre><code>sudo yum install python35<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u6aa2\u67e5 Python 3 \u7684\u7248\u672c\uff1a<\/p>\n<pre><code>python3.5 --version<\/code><\/pre>\n<h3 id=\"3-%e8%a8%ad%e7%bd%ae-python-3-%e7%82%ba%e9%bb%98%e8%aa%8d%e7%89%88%e6%9c%ac%ef%bc%88%e5%8f%af%e9%81%b8%ef%bc%89-RwLSuGIFEB\">3. \u8a2d\u7f6e Python 3 \u70ba\u9ed8\u8a8d\u7248\u672c\uff08\u53ef\u9078\uff09<\/h3>\n<p>\u5982\u679c\u60a8\u5e0c\u671b\u5c07 Python 3 \u8a2d\u7f6e\u70ba\u9ed8\u8a8d\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528 alternatives \u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo alternatives --set python \/usr\/bin\/python3.5<\/code><\/pre>\n<p>\u9019\u6a23\uff0c\u7576\u60a8\u8f38\u5165 `python` \u547d\u4ee4\u6642\uff0c\u7cfb\u7d71\u5c07\u4f7f\u7528 Python 3.5.2\u3002<\/p>\n<h3 id=\"4-%e5%ae%89%e8%a3%9d-pip-RwLSuGIFEB\">4. \u5b89\u88dd pip<\/h3>\n<p>\u70ba\u4e86\u65b9\u4fbf\u7ba1\u7406 Python \u5305\uff0c\u60a8\u53ef\u4ee5\u5b89\u88dd pip\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd pip\uff1a<\/p>\n<pre><code>sudo yum install python35-pip<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u6aa2\u67e5 pip \u7684\u7248\u672c\uff1a<\/p>\n<pre><code>pip3.5 --version<\/code><\/pre>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-RwLSuGIFEB\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u5347\u7d1a Python \u7248\u672c\u4e4b\u524d\uff0c\u5efa\u8b70\u60a8\u5099\u4efd\u7cfb\u7d71\u548c\u91cd\u8981\u6578\u64da\u3002\u6b64\u5916\uff0c\u67d0\u4e9b\u61c9\u7528\u7a0b\u5e8f\u53ef\u80fd\u4f9d\u8cf4\u65bc Python 2\uff0c\u56e0\u6b64\u5728\u5347\u7d1a\u5f8c\uff0c\u8acb\u78ba\u4fdd\u9019\u4e9b\u61c9\u7528\u7a0b\u5e8f\u4ecd\u7136\u6b63\u5e38\u904b\u884c\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-RwLSuGIFEB\">\u7e3d\u7d50<\/h2>\n<p>\u5c07 CentOS 7 \u4e2d\u7684 Python 2.7.5 \u5347\u7d1a\u5230 Python 3.5.2 \u662f\u4e00\u500b\u91cd\u8981\u7684\u6b65\u9a5f\uff0c\u80fd\u5920\u63d0\u9ad8\u958b\u767c\u6548\u7387\u548c\u4ee3\u78bc\u8cea\u91cf\u3002\u901a\u904e\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5b8c\u6210\u5347\u7d1a\u904e\u7a0b\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684\u74b0\u5883\u4f86\u904b\u884c\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u4ee5\u7372\u5f97\u66f4\u597d\u7684\u6027\u80fd\u548c\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to upgrade Python 2.7.5 to Python 3.5.2 on CentOS 7, ensuring compatibility and access to modern features for your applications.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43934","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43934"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43934\/revisions"}],"predecessor-version":[{"id":43935,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43934\/revisions\/43935"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}