{"id":156486,"date":"2019-09-08T10:22:39","date_gmt":"2019-09-08T02:22:39","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=156486"},"modified":"2019-08-26T09:23:41","modified_gmt":"2019-08-26T01:23:41","slug":"centos-7-python-3-7-python-2-7-5","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/centos-7-python-3-7-python-2-7-5.html","title":{"rendered":"\u6559\u4f60\u5982\u4f55\u5728 CentOS 7 \u4e0b\u7f16\u8bd1\u5b89\u88c5 Python 3.7 \u4e0e Python 2.7.5 \u5171\u5b58"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6559\u4f60\u5982\u4f55\u5728 CentOS 7 \u4e0b\u7f16\u8bd1\u5b89\u88c5 Python 3.7 \u4e0e Python 2.7.5 \u5171\u5b58\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u73af\u5883\uff1aCentOS<\/a> 7.6 x64<\/p>\n

\u4e00\u3001\u5b89\u88c5Python<\/a> 3.7<\/strong><\/div>\n
\u4e0b\u8f7dpython\u6e90\u7801\u5305\uff1a<\/strong><\/span><\/div>\n
wget https:\/\/www.python.org\/ftp\/python\/3.7.4\/Python-3.7.4.tgz<\/pre>\n

\u5982\u679c\u6ca1\u6709wget\u547d\u4ee4\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u5b89\u88c5\uff1ayum -y install wget<\/strong><\/p>\n

\u5b89\u88c5\u4f9d\u8d56\u5305\uff0c\u907f\u514d\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u7684 \"zipimport.ZipImportError<\/strong>\" \u9519\u8bef \u548c \"ModuleNotFoundError: No module named '_ctypes<\/strong>'\" \u9519\u8bef\uff1a<\/p>\n

yum -y install zlib-devel libffi-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make<\/pre>\n
\u89e3\u538b\u3001\u7f16\u8bd1\u3001\u5b89\u88c5\uff1a<\/strong><\/span><\/div>\n
tar -zxvf Python-3.7.4.tgz\r\ncd Python-3.7.4\r\n.\/configure --prefix=\/usr\/local\/python3 --enable-optimizations\r\nmake && make install<\/pre>\n
\u4fee\u6539\u73af\u5883\u53d8\u91cf\uff1a<\/strong><\/span><\/div>\n
vim \/etc\/profile<\/pre>\n

\u627e\u5230 \"export PATH<\/strong>\" \u5f00\u5934\u7684\u884c\uff0c\u5728\u6b64\u884c\u4e4b\u524d\uff0c\u63d2\u5165\u65b0\u884c\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n

PATH=$PATH:\/usr\/local\/python3\/bin\r\n#\u6ce8\u610f\uff1a\u7b49\u53f7\u4e24\u4fa7\u65e0\u7a7a\u683c\uff0c\u5192\u53f7:\u4e0d\u80fd\u7701<\/pre>\n
\u4fdd\u5b58\u9000\u51fa\uff0c\u6267\u884c\u547d\u4ee4\uff1a<\/strong><\/span><\/div>\n
source \/etc\/profile<\/pre>\n
\u73b0\u5728\u6211\u4eec\u770b\u4e00\u4e0b\u4e24\u4e2a\u7248\u672c\u7684python\u548cpip\u662f\u5426\u5171\u5b58\uff1a<\/strong><\/div>\n
[root@localhost ~]# python3 -V\r\nPython 3.7.4\r\n[root@localhost ~]# pip3 -V\r\npip 19.0.3 from \/usr\/local\/python3\/lib\/python3.7\/site-packages\/pip (python 3.7)\r\n\r\n[root@localhost ~]# python -V\r\nPython 2.7.5\r\n[root@localhost ~]# pip -V\r\npip 19.1.1 from \/usr\/lib\/python2.7\/site-packages\/pip (python 2.7)<\/pre>\n

\u56e0\u4e3a\u7cfb\u7edf\u7684yum\uff0c\u4ee5\u53ca\u5176\u4ed6\u7ec4\u4ef6\uff0c\u5747\u4f9d\u8d56python2.7.5\uff0c\u6240\u4ee5\u4e0d\u5efa\u8bae\u4f7f\u7528\u8f6f\u94fe\u63a5\u7684\u65b9\u5f0f\u66ff\u6362\u539f\u6765\u7684python2\u73af\u5883\u3002\u4f7f\u7528python3\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6309\u5982\u4e0b\u7684\u64cd\u4f5c\u5373\u53ef\uff1a<\/p>\n

pip3 install \u5305\u540d\r\npython3 -m pip install \u5305\u540d\r\npython3 -m pip install pymongo (\u5b89\u88c5Python3\u7684pymongo\u5305)\r\npython3 myscripts.py\r\npip3 install --upgrade pip (\u5347\u7ea7pip3\u7248\u672c)\r\n......<\/pre>\n

\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u73af\u5883\uff1aCentOS 7.6 x64 wget https:\/\/www.python.org\/ftp\/pytho […]<\/p>\n","protected":false},"author":63,"featured_media":156489,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-156486","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/156486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=156486"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/156486\/revisions"}],"predecessor-version":[{"id":157069,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/156486\/revisions\/157069"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/156489"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=156486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=156486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=156486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}