{"id":212,"date":"2018-02-12T17:18:37","date_gmt":"2018-02-12T09:18:37","guid":{"rendered":"http:\/\/www.inhhh.com\/blog\/?p=212"},"modified":"2018-02-12T17:18:37","modified_gmt":"2018-02-12T09:18:37","slug":"linux%e4%b8%8bpython%e5%ae%89%e8%a3%85%e5%8d%87%e7%ba%a7%e6%ad%a5%e9%aa%a4%e8%af%a6%e8%a7%a3-python2-%e5%8d%87%e7%ba%a7python3","status":"publish","type":"post","link":"http:\/\/www.inhhh.com\/blog\/?p=212","title":{"rendered":"Linux\u4e0bpython\u5b89\u88c5\u5347\u7ea7\u6b65\u9aa4\u8be6\u89e3 | Python2 \u5347\u7ea7Python3"},"content":{"rendered":"<div>\n<div>\n<p>Linux\u4e0bpython\u5347\u7ea7\u6b65\u9aa4 Python2 -&gt;Python3<br \/>\n\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u7cfb\u7edf\u81ea\u52a8\u7684Python\u7248\u672c\u662f2.x<br \/>\n\u6216\u8005yum\u76f4\u63a5\u5b89\u88c5\u7684\u4e5f\u662f2.x<br \/>\n\u4f46\u662f\uff0c\u73b0\u5728\u591a\u6570\u60c5\u51b5\u4e0b\u5efa\u8bae\u4f7f\u75283.x<br \/>\n\u90a3\u4e48\u5982\u4f55\u5347\u7ea7\u5462\uff1f<br \/>\n\u4e0b\u9762\u8001\u5f90\u8be6\u7ec6\u8bb2\u89e3\u5347\u7ea7\u6b65\u9aa4\uff1b<\/p>\n<p>\u9996\u5148\u4e0b\u8f7d\u6e90tar\u5305<br \/>\n\u53ef\u5229\u7528linux\u81ea\u5e26\u4e0b\u8f7d\u5de5\u5177wget\u4e0b\u8f7d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<br \/>\nwget <a href=\"https:\/\/link.jianshu.com?t=http:\/\/www.python.org\/ftp\/python\/3.3.0\/Python-3.3.0.tgz\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http:\/\/www.python.org\/ftp\/python\/3.3.0\/Python-3.3.0.tgz<\/a><\/p>\n<p>\u4e0b\u8f7d\u5b8c\u6210\u540e\u5230\u4e0b\u8f7d\u76ee\u5f55\u4e0b\uff0c\u89e3\u538b<br \/>\ntar -xzvf Python-3.3.0.tgz<\/p>\n<p>\u8fdb\u5165\u89e3\u538b\u7f29\u540e\u7684\u6587\u4ef6\u5939<br \/>\ncd Python-3.3.0<\/p>\n<p>\u5728\u7f16\u8bd1\u524d\u5148\u5728\/usr\/local\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939python3\uff08\u4f5c\u4e3apython\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u4ee5\u514d\u8986\u76d6\u8001\u7684\u7248\u672c\uff09<br \/>\nmkdir \/usr\/local\/python3<\/p>\n<p>\u5f00\u59cb\u7f16\u8bd1\u5b89\u88c5<br \/>\nbash .\/configure &#8211;prefix=\/usr\/local\/python3<br \/>\nmake<br \/>\nmake install<\/p>\n<p>\u6b64\u65f6\u6ca1\u6709\u8986\u76d6\u8001\u7248\u672c\uff0c\u518d\u5c06\u539f\u6765\/usr\/bin\/python\u94fe\u63a5\u6539\u4e3a\u522b\u7684\u540d\u5b57<br \/>\nmv \/usr\/bin\/python \/usr\/bin\/python_old2<\/p>\n<p>\u518d\u5efa\u7acb\u65b0\u7248\u672cpython\u7684\u94fe\u63a5<br \/>\nln -s \/usr\/local\/python3\/bin\/python3\/usr\/bin\/python<\/p>\n<p>\u8fd9\u4e2a\u65f6\u5019\u8f93\u5165<br \/>\npython -V<\/p>\n<p>\u5c31\u4f1a\u663e\u793a\u51fapython\u7684\u65b0\u7248\u672c\u4fe1\u606f<br \/>\n[idolaoxu@localhost home]# python -V<br \/>\nPython 3.3.0<\/p>\n<p>PS\uff1a\u5982\u679c\u4e0d\u5efa\u7acb\u65b0\u5b89\u88c5\u8def\u5f84python3\uff0c\u800c\u662f\u76f4\u63a5\u9ed8\u8ba4\u5b89\u88c5\uff0c\u5219\u5b89\u88c5\u540e\u7684\u65b0python\u5e94\u8be5\u4f1a\u8986\u76d6linux\u4e0b\u81ea\u5e26\u7684\u8001\u7248\u672c\uff0c\u4e5f\u6709\u53ef\u80fd\u4e0d\u8986\u76d6\uff0c\u5177\u4f53\u770b\u5b89\u88c5\u8fc7\u7a0b\u4e86\uff0c<br \/>\n\u8fd9\u4e2a\u5927\u5bb6\u53ef\u4ee5\u81ea\u5df1\u8bd5\u9a8c\u4e0b\uff0c\u5f53\u7136\u5982\u679c\u8fd8\u60f3\u4fdd\u7559\u539f\u6765\u7684\u7248\u672c\uff0c\u90a3\u4e48\u8fd9\u79cd\u65b9\u6cd5\u6700\u597d\u4e0d\u8fc7\u4e86\u3002<\/p>\n<p>&lt;pre&gt;<br \/>\n\u6700\u540e\u6269\u5145\u4e0b\uff0c<br \/>\n\u8fd9\u79cd\u65b9\u6cd5\u867d\u7136\u80fd\u5b89\u88c5\u6210\u529f\uff0c\u4f46\u662f\u5b83\u5e26\u6765\u4e86\u65b0\u7684\u95ee\u9898\uff0c\u6bd4\u5982yum\u4e0d\u80fd\u6b63\u5e38\u7528\u4e86<br \/>\n\u4fee\u6539\/usr\/bin\/yum\u7684\u7b2c\u4e00\u884c\u4e3a\uff1a<br \/>\n&#8216;#!\/usr\/bin\/python_old2<br \/>\n\u5c31\u53ef\u4ee5\u4e86<br \/>\n&lt;\/pre&gt;<br \/>\n\u5982\u4e0a\u662f\u8bb2\u89e3\u5df2\u7ecf\u5b58\u5728Python2\u7684\u60c5\u51b5\u4e0b\u5982\u4f55\u5347\u7ea7\uff0c\u5982\u679c\u662f\u7b2c\u4e00\u6b21\u5b89\u88c5\u5462\uff1f\u90a3\u66f4\u7b80\u5355\uff0c\u6709\u4e9b\u6b65\u9aa4\u76f4\u63a5\u53ef\u7701\u53bb\uff0c\u76f4\u63a5\u5b89\u88c5\u5c31OK<\/p>\n<\/div>\n<p>\u4f5c\u8005\uff1aIDO\u8001\u5f90<br \/>\n\u94fe\u63a5\uff1ahttps:\/\/www.jianshu.com\/p\/e422ea96c376<br \/>\n\u4f86\u6e90\uff1a\u7b80\u4e66<br \/>\n\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u4e0bpython\u5347\u7ea7\u6b65\u9aa4 Python2 -&gt;Python3 \u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u7cfb\u7edf\u81ea\u52a8\u7684Python<\/p>\n<div class=\"more-link\">\n\t\t\t\t <a href=\"http:\/\/www.inhhh.com\/blog\/?p=212\" class=\"link-btn theme-btn\"><span>Read More <\/span> <i class=\"fa fa-caret-right\"><\/i><\/a>\n\t\t\t<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":1,"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":213,"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions\/213"}],"wp:attachment":[{"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.inhhh.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}