{"id":3000,"date":"2017-12-31T09:29:28","date_gmt":"2017-12-31T01:29:28","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=3000"},"modified":"2017-12-31T09:33:14","modified_gmt":"2017-12-31T01:33:14","slug":"centos7%e4%bf%9d%e7%95%99%e9%bb%98%e8%ae%a4python%e7%89%88%e6%9c%ac%e5%b9%b6%e5%ae%89%e8%a3%85%e6%9b%b4%e6%96%b0python2%e5%92%8cpython3%e5%85%b1%e5%ad%98","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/jishu\/python\/centos7%e4%bf%9d%e7%95%99%e9%bb%98%e8%ae%a4python%e7%89%88%e6%9c%ac%e5%b9%b6%e5%ae%89%e8%a3%85%e6%9b%b4%e6%96%b0python2%e5%92%8cpython3%e5%85%b1%e5%ad%98\/","title":{"rendered":"CentOS7\u4fdd\u7559\u9ed8\u8ba4Python\u7248\u672c\u5e76\u5b89\u88c5\u66f4\u65b0Python2\u548cPython3\u5171\u5b58"},"content":{"rendered":"<p>CentOS 7 \u9ed8\u8ba4\u7684python\u7248\u672c\u662fpython2.7.5\u3002\u56e0\u4e3ayum\u4f9d\u8d56\u4e8e\u9ed8\u8ba4\u7684python\u7248\u672c\u7684\u7f18\u7531\uff0c\u6240\u4ee5\u8981\u5148\u4fdd\u7559\u9ed8\u8ba4\u7248\u672c\uff0c\u5e76\u4fee\u6539yum\u6587\u4ef6\u5934\u90e8\u540e\uff0c\u624d\u80fd\u5f00\u59cb\u5b89\u88c5\u66f4\u65b0python2\u548cpython3\u4e24\u4e2a\u6700\u65b0\u7248\u672c\u3002\uff08python2\u548cpython3\u5171\u5b58\uff09<\/p>\n<p>\u4e00. \u4fdd\u7559\u9ed8\u8ba4python\u7248\u672c2.7.5\uff0c\u5e76\u4fee\u6539yum\u5934\u90e8\uff0c\u4fdd\u6301yum\u5bf9\u9ed8\u8ba4\u7248\u672cpython2.7.5\u7684\u4f9d\u8d56<\/p>\n<p>1.su root\u3000\u3000# \u83b7\u53d6root\u6743\u9650<\/p>\n<p>2.mv \/usr\/bin\/python2.7 \/usr\/bin\/python2.7.5\u3000\u3000# \u4fdd\u7559\u9ed8\u8ba4\u7248\u672cpython\u4e3apython2.7.5<\/p>\n<p>ln -s \/usr\/bin\/python2.7.5 \/usr\/local\/bin\/python2.7.5\u3000\u3000# \u521b\u5efa\u8f6f\u8fde\u63a5<br \/>\n3.ll \/usr\/bin\/yum*\u3000\u3000# \u67e5\u770b\/usr\/bin\/\u76ee\u5f55\u4e0b\u6240\u6709yum\u6587\u4ef6\uff087\u4e2a\uff09\u5934\u90e8<\/p>\n<p>4.vi \/usr\/bin\/yum*\u3000\u3000# \u4fee\u6539\/usr\/bin\/\u76ee\u5f55\u4e0b\u6240\u6709yum\u6587\u4ef6\uff087\u4e2a\uff09\u5934\u90e8<\/p>\n<p>#!\/usr\/bin\/python \u2014&gt; #!\/usr\/bin\/python2.7.5<\/p>\n<p>5.vi \/usr\/libexec\/urlgrabber-ext-down\u3000\u3000# \u4fee\u6539\/usr\/libexec\/\u76ee\u5f55\u4e0b urlgrabber-ext-down\u5934\u90e8<\/p>\n<p>#!\/usr\/bin\/python \u2014&gt; #!\/usr\/bin\/python2.7.5<\/p>\n<p>\u4e8c. \u5b89\u88c5\u6700\u65b0\u7248python2.7.13\u548cpython3.6.2\uff08python2\u548cpython3\u5171\u5b58\uff0c\u4fee\u6539\u540e\u9ed8\u8ba4\u7248\u672c\u4e3apython3.6.2\uff09<\/p>\n<p>\u51c6\u5907\u5de5\u4f5c\uff1a<\/p>\n<p>1. \u5b89\u88c5wget\u547d\u4ee4\uff08\u53ef\u4ee5\u5728\u7ebf\u4e0b\u8f7d\u5b89\u88c5\u5305\u7684\u547d\u4ee4\uff09<\/p>\n<p>yum -y install wget<\/p>\n<p>2. \u51c6\u5907\u7f16\u8bd1\u73af\u5883<\/p>\n<p>yum groupinstall &#8216;Development Tools&#8217;<br \/>\nyum install zlib-devel bzip2-devel openssl-devel ncurses-devel<br \/>\n3. \u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684python2\u548cpython3\u7684tgz\u538b\u7f29\u6587\u4ef6<\/p>\n<p>https:\/\/www.python.org\/ftp\/python\/2.7.13\/Python-2.7.13.tgz<br \/>\nhttps:\/\/www.python.org\/ftp\/python\/3.6.2\/Python-3.6.2.tgz<\/p>\n<p>\u5f00\u59cb\u5b89\u88c5\uff1a<\/p>\n<p>1. \u8fdb\u5165\u4e0b\u8f7d\u76ee\u5f55\uff1a<\/p>\n<p>cd \/usr\/local\/src<\/p>\n<p>2. \u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672cpython2\uff1a<br \/>\nwget https:\/\/www.python.org\/ftp\/python\/2.7.13\/Python-2.7.13.tgz<br \/>\ntar zxvf Python-2.7.13.tgz<br \/>\ncd Python-2.7.13<br \/>\n.\/configure<br \/>\nmake all<br \/>\nmake install<br \/>\nmake clean<br \/>\nmake distclean<br \/>\nrm -rf \/usr\/bin\/python<br \/>\nrm -rf \/usr\/bin\/python2<br \/>\nrm -rf \/usr\/bin\/python2.7<br \/>\nln -s \/usr\/local\/bin\/python2.7 \/usr\/bin\/python<br \/>\nln -s \/usr\/local\/bin\/python2.7 \/usr\/bin\/python2<br \/>\nln -s \/usr\/local\/bin\/python2.7 \/usr\/bin\/python2.7<br \/>\n\/usr\/bin\/python -V<br \/>\n\/usr\/bin\/python2 -V<br \/>\n\/usr\/bin\/python2.7 -V<br \/>\nrm -rf \/usr\/local\/bin\/python<br \/>\nrm -rf \/usr\/local\/bin\/python2<br \/>\nln -s \/usr\/local\/bin\/python2.7 \/usr\/local\/bin\/python<br \/>\nln -s \/usr\/local\/bin\/python2.7 \/usr\/local\/bin\/python2<br \/>\npython -V<br \/>\npython2 -V<br \/>\npython2.7 -V<\/p>\n<p>3. \u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672cpython3\uff1a<br \/>\nwget https:\/\/www.python.org\/ftp\/python\/3.6.2\/Python-3.6.2.tgz<br \/>\ntar zxvf Python-3.6.2.tgz<br \/>\ncd Python-3.6.2<br \/>\n.\/configure<br \/>\nmake all<br \/>\nmake install<br \/>\nmake clean<br \/>\nmake distclean<br \/>\nrm -rf \/usr\/bin\/python<br \/>\nrm -rf \/usr\/bin\/python3<br \/>\nrm -rf \/usr\/bin\/python3.6<br \/>\nln -s \/usr\/local\/bin\/python3.6 \/usr\/bin\/python<br \/>\nln -s \/usr\/local\/bin\/python3.6 \/usr\/bin\/python3<br \/>\nln -s \/usr\/local\/bin\/python3.6 \/usr\/bin\/python3.6<br \/>\n\/usr\/bin\/python -V<br \/>\n\/usr\/bin\/python3 -V<br \/>\n\/usr\/bin\/python3.6 -V<br \/>\nrm -rf \/usr\/local\/bin\/python<br \/>\nrm -rf \/usr\/local\/bin\/python3<br \/>\nln -s \/usr\/local\/bin\/python3.6 \/usr\/local\/bin\/python<br \/>\nln -s \/usr\/local\/bin\/python3.6 \/usr\/local\/bin\/python3<br \/>\npython -V<br \/>\npython3 -V<br \/>\npython3.6 -V<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS 7 \u9ed8\u8ba4\u7684python\u7248\u672c\u662fpython2.7.5\u3002\u56e0\u4e3ayum\u4f9d\u8d56\u4e8e\u9ed8\u8ba4\u7684python\u7248\u672c\u7684\u7f18\u7531 &#8230; <a title=\"CentOS7\u4fdd\u7559\u9ed8\u8ba4Python\u7248\u672c\u5e76\u5b89\u88c5\u66f4\u65b0Python2\u548cPython3\u5171\u5b58\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/jishu\/python\/centos7%e4%bf%9d%e7%95%99%e9%bb%98%e8%ae%a4python%e7%89%88%e6%9c%ac%e5%b9%b6%e5%ae%89%e8%a3%85%e6%9b%b4%e6%96%b0python2%e5%92%8cpython3%e5%85%b1%e5%ad%98\/\" aria-label=\"\u9605\u8bfb CentOS7\u4fdd\u7559\u9ed8\u8ba4Python\u7248\u672c\u5e76\u5b89\u88c5\u66f4\u65b0Python2\u548cPython3\u5171\u5b58\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[654],"tags":[380],"class_list":["post-3000","post","type-post","status-publish","format-standard","hentry","category-python","tag-python"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=3000"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3000\/revisions"}],"predecessor-version":[{"id":3001,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3000\/revisions\/3001"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=3000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=3000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=3000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}