{"id":4685,"date":"2023-02-21T17:50:50","date_gmt":"2023-02-21T09:50:50","guid":{"rendered":"https:\/\/km94.com\/?p=4685"},"modified":"2023-02-21T17:50:50","modified_gmt":"2023-02-21T09:50:50","slug":"linux%e7%b3%bb%e7%bb%9f%ef%bc%9acentos7%e5%ae%89%e8%a3%85python3-7%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/dy208.cn\/index.php\/2023\/02\/21\/linux%e7%b3%bb%e7%bb%9f%ef%bc%9acentos7%e5%ae%89%e8%a3%85python3-7%e6%95%99%e7%a8%8b\/","title":{"rendered":"Linux\u7cfb\u7edf\uff1aCentOS7\u5b89\u88c5python3.7\u6559\u7a0b"},"content":{"rendered":"<p>CentOS\u662fLinux\u53d1\u884c\u7248\u4e4b\u4e00\uff0c\u5b83\u662f\u6765\u81ea\u4e8eRed Hat Enterprise Linux\u4f9d\u7167\u5f00\u653e\u6e90\u4ee3\u7801\u89c4\u5b9a\u91ca\u51fa\u7684\u6e90\u4ee3\u7801\u6240\u7f16\u8bd1\u800c\u6210\u3002\u672c\u6559\u7a0b\u662f\u5728CentOS\u4e0b\u7528yum\u5728\u7ebf\u5b89\u88c5python3.7(\u4e5f\u53ef\u4ee5\u9009\u62e9\u5176\u4ed6\u7248\u672c\uff09\uff0c\u6b65\u9aa4\u5f88\u8be6\u7ec6\uff0c\u6211\u81ea\u5df1\u8d70\u8fc7\uff0c\u6ca1\u6709\u9519\u8bef\uff0c\u6309\u7740\u8fd9\u4e2a\u6d41\u7a0b\u6765\uff0c\u57fa\u672c\u4e0a\u4e0d\u4f1a\u51fa\u9519\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u68c0\u67e5\u7cfb\u7edf\u662f\u5426\u6709gcc<\/p>\n<p>gcc &#8211;version \u2014\u2014\u67e5\u8be2\u662f\u5426<\/p>\n<p>gcc -v \u2014\u2014\u67e5\u8be2\u7248\u672c<\/p>\n<p>\n\t<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-4687\" alt=\"centos7\u5b89\u88c5python3.7\u6559\u7a0b\" src=\"https:\/\/km94.com\/wp-content\/uploads\/2023\/02\/centos7.jpg\"><\/figure>\n\t<\/p>\n<p>\u7b2c\u4e8c\u6b65\u3001\u5982\u679c\u6ca1\u6709\u663e\u793a\u5c31\u6267\u884c\u4e0b\u9762yum\u5b89\u88c5gcc<\/p>\n<p># yum search gcc<\/p>\n<p># yum -y install gcc<\/p>\n<p>\u7b2c\u4e09\u6b65\u3001\u5b89\u88c5python3.7\u4e4b\u524d\u9700\u8981\u5148\u5b89\u88c5\u4e0b\u4f9d\u8d56\u5e93<\/p>\n<p># yum -y groupinstall &#8220;Development tools&#8221;<\/p>\n<p># yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel<\/p>\n<p># yum install libffi-devel -y<\/p>\n<p>\u7b2c\u56db\u6b65\u3001\u4e0b\u8f7d\u5b89\u88c5\u5305\u89e3\u538b(\u53ef\u4ee5\u5230\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\uff0cwget\u540e\u9762\u52a0\u4e0b\u8f7d\u5730\u5740)<\/p>\n<p># wget https:\/\/www.python.org\/ftp\/python\/3.7.0\/Python-3.7.0.tar.xz<\/p>\n<p># tar -xvJf Python-3.7.0.tar.xz<\/p>\n<p>\u7b2c\u4e94\u6b65\u3001\u7f16\u8bd1\u5b89\u88c5<\/p>\n<p>[root]# tar xvf Python-3.7.0.tar.xz<\/p>\n<p>[root]# mv Python-3.7.0 \/usr\/local\/python-3.7<\/p>\n<p>[root]# cd \/usr\/local\/python-3.7\/<\/p>\n<p>\u7b2c\u516d\u6b65\u3001\u5c06python3.7\u5b89\u88c5\u5230\/usr\/local\/sbin\/python-3.7\u76ee\u5f55\u4e0b<\/p>\n<p>[root python-3.7]# .\/configure &#8211;prefix=\/usr\/local\/sbin\/python-3.7<\/p>\n<p>[root python-3.7]# make &amp;&amp; make install<\/p>\n<p>\u7b2c\u4e03\u6b65\u3001\u5b89\u88c5\u6210\u529f\u4e4b\u540e\u4f7f\u7528<\/p>\n<p>[root python-3.7]# \/usr\/local\/sbin\/python-3.7\/bin\/python3<\/p>\n<p>Python 3.7.0 (default, Mar 15 2019, 00:44:37)<\/p>\n<p>[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux<\/p>\n<p>Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<\/p>\n<p>&gt;&gt;&gt;exit<\/p>\n<p>\u7b2c\u516b\u6b65\u3001\u67e5\u770bpython\u547d\u4ee4\u7684\u7edd\u5bf9\u8def\u5f84<\/p>\n<p>[root@python3 ~]# which python<\/p>\n<p>\/usr\/bin\/python<\/p>\n<p>\u7b2c\u4e5d\u6b65\u3001\u521b\u5efa\u8f6f\u8fde\u63a5\u4ee5\u53ca\u73af\u5883\u53d8\u91cf<\/p>\n<p>ln -sv \/usr\/local\/sbin\/python-3.7\/bin\/python3 \/usr\/bin\/python3<\/p>\n<p>ln -s \/usr\/local\/sbin\/python-3.7\/bin\/pip3 \/usr\/bin\/pip3<\/p>\n<p>\u7b2c\u5341\u6b65\u3001\u6700\u7ec8\uff0c\u67e5\u770b\u7ed3\u679c\uff1a<\/p>\n<p>ln -sv \/usr\/local\/sbin\/python-3.7\/bin\/python3 \/usr\/bin\/python3<\/p>\n<p>ln -s \/usr\/local\/sbin\/python-3.7\/bin\/pip3 \/usr\/bin\/pip3<\/p>\n<p>\u53ef\u4ee5\u770b\u5230python2\u6307\u5411\u4e862.7\u7248\u672c\uff0cpython3\u6307\u5411\u4e863.7\u7248\u672c\uff1b<\/p>\n<p>\u7b2c\u5341\u4e00\u6b65\u3001\u521b\u5efa\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<p># vim .bash_profile<\/p>\n<p>\u4fee\u6539\u6210\u8fd9\u53e5\u4ee3\u7801:PATH=$PATH:\/usr\/local\/sbin\/python-3.7\/bin<\/p>\n<p>\u4fdd\u5b58\u9000\u51fa\u6267\u884c<\/p>\n<p>#source .bash_profile<\/p>\n<p>\u9a8c\u8bc1\u662f\u5426\u6210\u529f\uff1f<\/p>\n<p>python3 -V<\/p>\n<p>pip3 -V<\/p>\n<p>\n\t<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-4688\" alt=\"centos7\u5b89\u88c5python3.7\u6559\u7a0b\" src=\"https:\/\/km94.com\/wp-content\/uploads\/2023\/02\/centos.jpg\"><\/figure>\n\t<\/p>\n<p>\u6ce8\u610f\uff1a\u53ef\u80fd\u4f60\u4f1a\u7528\u4e0a\u5176\u5b83\u7684\u76f8\u5173\u547d\u4ee4\uff0c\u5982\u4e0b\uff1a<\/p>\n<p># \u5378\u8f7dpython3<\/p>\n<p>rpm -qa|grep python3|xargs rpm -ev &#8211;allmatches &#8211;nodeps<\/p>\n<p># \u5220\u9664\u6b8b\u7559\u6587\u4ef6<\/p>\n<p>whereis python3 |xargs rm -frv<\/p>\n<p># \u67e5\u770b\u73b0\u6709\u5b89\u88c5\u7684python<\/p>\n<p>whereis python<\/p>\n\n<div>\n<div>\n\n\n\n<\/div>\n<div>\n\n\n\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>CentOS\u662fLinux\u53d1\u884c\u7248\u4e4b\u4e00\uff0c\u5b83\u662f\u6765\u81ea\u4e8eRed Hat Enterprise Linux\u4f9d\u7167\u5f00\u653e\u6e90\u4ee3\u7801\u89c4&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4686,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,2],"tags":[],"class_list":["post-4685","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web","category-jc","entry"],"_links":{"self":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/posts\/4685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/comments?post=4685"}],"version-history":[{"count":0,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/posts\/4685\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/media?parent=4685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/categories?post=4685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/tags?post=4685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}