{"id":93328,"date":"2024-04-17T18:50:11","date_gmt":"2024-04-17T10:50:11","guid":{"rendered":"http:\/\/gulass.cn\/?p=93328"},"modified":"2024-04-17T18:50:11","modified_gmt":"2024-04-17T10:50:11","slug":"linux-centos7-python3","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-centos7-python3.html","title":{"rendered":"\u5728Linux CentOS7 \u4e0b\u5b89\u88c5 python3"},"content":{"rendered":"

\u5728CentOS7\u4e0b\uff0c\u9ed8\u8ba4\u5b89\u88c5\u7684\u5c31\u662fpython2.7\uff0c\u6211\u73b0\u5728\u6765\u6559\u5927\u5bb6\u5982\u4f55\u5b89\u88c5python3\uff1a<\/p>\n

1\u3001\u9996\u5148\u5b89\u88c5python3.6\u53ef\u80fd\u4f7f\u7528\u7684\u4f9d\u8d56<\/p>\n

# yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel zlib-devel<\/pre>\n

2\u3001\u4e0b\u8f7dpython\u6e90\u7801\u5305\uff0c\u5730\u5740\u4e3ahttps:\/\/www.python.org\/downloads\/source\/\uff0c\u7136\u540e\u901a\u8fc7xftp\u4e0a\u4f20\u4e0a\u53bb\uff0c\u6216\u8005\u76f4\u63a5\u4f7f\u7528wget\u547d\u4ee4\uff0cwget https:\/\/www.python.org\/ftp\/python\/3.6.1\/Python-3.6.1.tgz\u4e0b\u8f7d\u5230\u672c\u5730<\/p>\n

# tar -zxvf Python-3.6.1.tgz\r\n# cd Python-3.6.1\/<\/pre>\n

3\u3001\u628apython3.6\u5b89\u88c5\u5230\/usr\/local\u76ee\u5f55\u4e0b<\/p>\n

# .\/configure --prefix=\/usr\/local\/\r\n# make\r\n# make altinstall<\/pre>\n

4\u3001\u66f4\u6539\/usr\/bin\/python\u94fe\u63a5<\/p>\n

# cd \/usr\/bin\r\n# mv python python.backup\r\n# ln -s \/usr\/local\/bin\/python3.6 \/usr\/bin\/python\r\n# ln -s \/usr\/local\/bin\/python3.6 \/usr\/bin\/python3\r\n# rm -rf \/usr\/bin\/python2\r\n# ln -s \/usr\/bin\/python2.7 \/usr\/bin\/python2<\/pre>\n

5\u3001\u66f4\u6539yum\u811a\u672c\u7684python\u4f9d\u8d56<\/p>\n

# cd \/usr\/bin\r\n# ll yum*<\/pre>\n

\u6709\u4ee5\u4e0b\u6587\u4ef6\uff1a<\/p>\n

-rwxr-xr-x 1 root root 802 Jan 2 17:53 yum\r\n-rwxr-xr-x 1 root root 9374 Jan 2 17:53 yum-builddep\r\n-rwxr-xr-x 1 root root 8091 Jan 2 17:53 yum-config-manager\r\n-rwxr-xr-x 1 root root 7610 Jan 2 17:53 yum-debug-dump\r\n-rwxr-xr-x 1 root root 7904 Jan 2 17:54 yum-debug-restore\r\n-rwxr-xr-x 1 root root 10906 Jan 2 17:54 yumdownloader\r\n-rwxr-xr-x 1 root root 11032 Jan 2 17:54 yum-groups-manager<\/pre>\n

\u4fee\u6539\u4ee5\u4e0a\u6587\u4ef6\u5934\uff1a#!\/usr\/bin\/python \u6539\u4e3a #!\/usr\/bin\/python2<\/p>\n

\u53ef\u4ee5\u5b89\u88c5\u4e00\u4e2atree\u6d4b\u8bd5\u4e00\u4e0b<\/p>\n

# yum -y install tree<\/pre>\n

\u5982\u679c\u51fa\u73b0\u4ee5\u4e0b\u62a5\u9519\uff1aFile \u201c\/usr\/libexec\/urlgrabber-ext-down\u201d, line 28<\/p>\n

vim \/usr\/libexec\/urlgrabber-ext-down<\/pre>\n

\u5c06\/usr\/bin\/python\u6539\u4e3a\/usr\/bin\/python2\u5373\u53ef<\/p>\n

\u8fd9\u6837\uff0cyum\u5b89\u88c5\u8f6f\u4ef6\u7684\u65f6\u5019\u5c31\u4e0d\u4f1a\u62a5\u9519\u4e86\uff0c\u800c\u4e14\u9ed8\u8ba4\u5b89\u88c5\u7684\u5c31\u662fpython3\u4e86\uff0c\u8f93\u5165python\u65f6\uff0c\u5c31\u4f1a\u8fdb\u5165python3\u754c\u9762\uff0c\u5982\u679c\u60f3\u8fdb\u5165python2\uff0c\u90a3\u4e48\u5c31\u8f93\u5165python2\u597d\u4e86\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/www.cnblogs.com\/xiaoyafei\/p\/8321015.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/gulass.cn\/linux-centos7-python3.html <\/a>\u7f16\u8f91\uff1a\u59dc\u663e\u8d6b\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5728CentOS7\u4e0b\uff0c\u9ed8\u8ba4\u5b89\u88c5\u7684\u5c31\u662fpython2.7\uff0c\u6211\u73b0\u5728\u6765\u6559\u5927\u5bb6\u5982\u4f55\u5b89\u88c5python3\uff1a 1\u3001\u9996\u5148\u5b89\u88c5py […]<\/p>\n","protected":false},"author":370,"featured_media":92457,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-93328","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/93328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=93328"}],"version-history":[{"count":7,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/93328\/revisions"}],"predecessor-version":[{"id":93566,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/93328\/revisions\/93566"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/92457"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=93328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=93328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=93328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}