{"id":42452,"date":"2024-10-03T13:46:27","date_gmt":"2024-10-03T05:46:27","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42452\/"},"modified":"2024-10-03T13:46:28","modified_gmt":"2024-10-03T05:46:28","slug":"centos-6-4-%e5%8d%87%e7%b4%9a-python-%e9%81%8e%e7%a8%8b%e7%b8%bd%e7%b5%90","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42452\/","title":{"rendered":"CentOS 6.4 \u5347\u7d1a Python \u904e\u7a0b\u7e3d\u7d50"},"content":{"rendered":"<h1 id=\"centos-6-4-%e5%8d%87%e7%b4%9a-python-%e9%81%8e%e7%a8%8b%e7%b8%bd%e7%b5%90-vtlThdtjGg\">CentOS 6.4 \u5347\u7d1a Python \u904e\u7a0b\u7e3d\u7d50<\/h1>\n<p>\u5728\u7576\u524d\u7684\u958b\u767c\u74b0\u5883\u4e2d\uff0cPython \u5df2\u7d93\u6210\u70ba\u4e00\u7a2e\u4e0d\u53ef\u6216\u7f3a\u7684\u7de8\u7a0b\u8a9e\u8a00\u3002\u96a8\u8457\u7248\u672c\u7684\u66f4\u65b0\uff0c\u8a31\u591a\u958b\u767c\u8005\u9700\u8981\u5728\u5176\u4f3a\u670d\u5668\u4e0a\u5347\u7d1a Python \u4ee5\u7372\u5f97\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u6027\u3002\u672c\u6587\u5c07\u91dd\u5c0d CentOS 6.4 \u7cfb\u7d71\u4e0a\u5347\u7d1a Python \u7684\u904e\u7a0b\u9032\u884c\u8a73\u7d30\u7e3d\u7d50\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u597d\u5730\u7406\u89e3\u548c\u5be6\u65bd\u9019\u4e00\u904e\u7a0b\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%9c%80%e8%a6%81%e5%8d%87%e7%b4%9a-python%ef%bc%9f-vtlThdtjGg\">\u70ba\u4ec0\u9ebc\u9700\u8981\u5347\u7d1a Python\uff1f<\/h2>\n<p>Python \u7684\u6bcf\u500b\u65b0\u7248\u672c\u90fd\u6703\u5e36\u4f86\u6027\u80fd\u7684\u63d0\u5347\u548c\u5b89\u5168\u6f0f\u6d1e\u7684\u4fee\u5fa9\u3002CentOS 6.4 \u9ed8\u8a8d\u5b89\u88dd\u7684 Python \u7248\u672c\u901a\u5e38\u8f03\u820a\uff0c\u9019\u53ef\u80fd\u6703\u5c0e\u81f4\u4e00\u4e9b\u73fe\u4ee3\u61c9\u7528\u7a0b\u5e8f\u7121\u6cd5\u6b63\u5e38\u904b\u884c\u3002\u56e0\u6b64\uff0c\u5347\u7d1a Python \u662f\u78ba\u4fdd\u7cfb\u7d71\u5b89\u5168\u548c\u61c9\u7528\u7a0b\u5e8f\u517c\u5bb9\u6027\u7684\u5fc5\u8981\u6b65\u9a5f\u3002<\/p>\n<h2 id=\"%e5%8d%87%e7%b4%9a%e5%89%8d%e7%9a%84%e6%ba%96%e5%82%99-vtlThdtjGg\">\u5347\u7d1a\u524d\u7684\u6e96\u5099<\/h2>\n<p>\u5728\u9032\u884c\u5347\u7d1a\u4e4b\u524d\uff0c\u5efa\u8b70\u7528\u6236\u5148\u5099\u4efd\u91cd\u8981\u6578\u64da\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u5099\u4efd\uff1a<\/p>\n<pre><code>tar -czvf backup.tar.gz \/path\/to\/important\/files<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u78ba\u4fdd\u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\uff0c\u9019\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u5b8c\u6210\uff1a<\/p>\n<pre><code>sudo yum update<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d%e5%bf%85%e8%a6%81%e7%9a%84%e4%be%9d%e8%b3%b4%e5%8c%85-vtlThdtjGg\">\u5b89\u88dd\u5fc5\u8981\u7684\u4f9d\u8cf4\u5305<\/h2>\n<p>\u5728\u5347\u7d1a Python \u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u4f9d\u8cf4\u5305\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum groupinstall \"Development Tools\"<\/code><\/pre>\n<pre><code>sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel<\/code><\/pre>\n<h2 id=\"%e4%b8%8b%e8%bc%89%e5%92%8c%e5%ae%89%e8%a3%9d%e6%9c%80%e6%96%b0%e7%89%88%e6%9c%ac%e7%9a%84-python-vtlThdtjGg\">\u4e0b\u8f09\u548c\u5b89\u88dd\u6700\u65b0\u7248\u672c\u7684 Python<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5f9e\u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684 Python\u3002\u4ee5 Python 3.8.10 \u70ba\u4f8b\uff1a<\/p>\n<pre><code>wget https:\/\/www.python.org\/ftp\/python\/3.8.10\/Python-3.8.10.tgz<\/code><\/pre>\n<p>\u89e3\u58d3\u4e0b\u8f09\u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar xzf Python-3.8.10.tgz<\/code><\/pre>\n<p>\u9032\u5165\u89e3\u58d3\u5f8c\u7684\u76ee\u9304\uff1a<\/p>\n<pre><code>cd Python-3.8.10<\/code><\/pre>\n<p>\u7136\u5f8c\u904b\u884c\u914d\u7f6e\u8173\u672c\uff1a<\/p>\n<pre><code>.\/configure --enable-optimizations<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u7de8\u8b6f\u4e26\u5b89\u88dd Python\uff1a<\/p>\n<pre><code>make altinstall<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u907f\u514d\u8986\u84cb\u7cfb\u7d71\u81ea\u5e36\u7684 Python \u7248\u672c\u3002<\/p>\n<h2 id=\"%e9%a9%97%e8%ad%89%e5%ae%89%e8%a3%9d-vtlThdtjGg\">\u9a57\u8b49\u5b89\u88dd<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 Python \u7684\u7248\u672c\uff1a<\/p>\n<pre><code>python3.8 --version<\/code><\/pre>\n<p>\u5982\u679c\u986f\u793a\u6b63\u78ba\u7684\u7248\u672c\u865f\uff0c\u5247\u8868\u793a\u5347\u7d1a\u6210\u529f\u3002<\/p>\n<h2 id=\"%e6%9b%b4%e6%96%b0-pip-%e5%92%8c%e5%ae%89%e8%a3%9d%e8%99%9b%e6%93%ac%e7%92%b0%e5%a2%83-vtlThdtjGg\">\u66f4\u65b0 pip \u548c\u5b89\u88dd\u865b\u64ec\u74b0\u5883<\/h2>\n<p>\u5347\u7d1a Python \u5f8c\uff0c\u5efa\u8b70\u66f4\u65b0 pip \u4ee5\u7372\u5f97\u6700\u65b0\u7684\u5305\u7ba1\u7406\u529f\u80fd\uff1a<\/p>\n<pre><code>python3.8 -m ensurepip<\/code><\/pre>\n<pre><code>python3.8 -m pip install --upgrade pip<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u70ba\u4e86\u66f4\u597d\u5730\u7ba1\u7406 Python \u74b0\u5883\uff0c\u53ef\u4ee5\u5b89\u88dd\u865b\u64ec\u74b0\u5883\u5de5\u5177\uff1a<\/p>\n<pre><code>python3.8 -m pip install virtualenv<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-vtlThdtjGg\">\u7e3d\u7d50<\/h2>\n<p>\u5347\u7d1a CentOS 6.4 \u4e0a\u7684 Python \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u53ea\u9700\u9075\u5faa\u4e0a\u8ff0\u6b65\u9a5f\u5373\u53ef\u5b8c\u6210\u3002\u9019\u4e0d\u50c5\u80fd\u63d0\u9ad8\u7cfb\u7d71\u7684\u5b89\u5168\u6027\uff0c\u9084\u80fd\u78ba\u4fdd\u61c9\u7528\u7a0b\u5e8f\u7684\u517c\u5bb9\u6027\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u904b\u884c\u7684\u4f3a\u670d\u5668\u74b0\u5883\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4e5f\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u7121\u8ad6\u662f\u9078\u64c7 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684\u670d\u52d9\uff0c\u78ba\u4fdd\u60a8\u7684\u4f3a\u670d\u5668\u80fd\u5920\u652f\u6301\u6700\u65b0\u7684\u6280\u8853\u548c\u9700\u6c42\uff0c\u5c07\u6709\u52a9\u65bc\u63d0\u5347\u6574\u9ad4\u7684\u904b\u884c\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7e3d\u7d50CentOS 6.4\u5347\u7d1aPython\u7684\u904e\u7a0b\uff0c\u6db5\u84cb\u6b65\u9a5f\u3001\u6ce8\u610f\u4e8b\u9805\u53ca\u5e38\u898b\u554f\u984c\uff0c\u52a9\u4f60\u9806\u5229\u5b8c\u6210\u5347\u7d1a\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-42452","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=42452"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42452\/revisions"}],"predecessor-version":[{"id":42453,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42452\/revisions\/42453"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}