{"id":1075657,"date":"2025-01-08T11:46:12","date_gmt":"2025-01-08T03:46:12","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1075657.html"},"modified":"2025-01-08T11:46:14","modified_gmt":"2025-01-08T03:46:14","slug":"centos7%e5%a6%82%e4%bd%95%e4%b8%8b%e8%bd%bd%e5%ae%89%e8%a3%85python-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1075657.html","title":{"rendered":"centos7\u5982\u4f55\u4e0b\u8f7d\u5b89\u88c5Python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24180626\/cc31c8aa-6e69-4bd9-bded-c4f69094d0c7.webp\" alt=\"centos7\u5982\u4f55\u4e0b\u8f7d\u5b89\u88c5Python\" \/><\/p>\n<p><p> \u5728CentOS 7\u4e0a\u4e0b\u8f7d\u5b89\u88c5Python\u6d89\u53ca\u51e0\u4e2a\u6b65\u9aa4\uff1a<strong>\u786e\u4fdd\u7cfb\u7edf\u66f4\u65b0\u3001\u5b89\u88c5\u5f00\u53d1\u5de5\u5177\u3001\u4e0b\u8f7dPython\u6e90\u7801\u3001\u7f16\u8bd1\u548c\u5b89\u88c5Python\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\u3002\u5176\u4e2d\uff0c\u786e\u4fdd\u7cfb\u7edf\u66f4\u65b0\u662f\u6700\u91cd\u8981\u7684\u6b65\u9aa4\u4e4b\u4e00\uff0c\u56e0\u4e3a\u5b83\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u5177\u6709\u6700\u65b0\u7684\u5b89\u5168\u8865\u4e01\u548c\u8f6f\u4ef6\u5305\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u786e\u4fdd\u7cfb\u7edf\u66f4\u65b0<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4efb\u4f55\u8f6f\u4ef6\u5b89\u88c5\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u7684CentOS 7\u7cfb\u7edf\u662f\u6700\u65b0\u7684\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b8c\u6210\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum update -y<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u66f4\u65b0\u6240\u6709\u73b0\u6709\u7684\u8f6f\u4ef6\u5305\uff0c\u5e76\u786e\u4fdd\u4f60\u62e5\u6709\u6700\u65b0\u7684\u5b89\u5168\u8865\u4e01\u548c\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5b89\u88c5\u5f00\u53d1\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u8981\u7f16\u8bd1\u548c\u5b89\u88c5Python\uff0c\u4f60\u9700\u8981\u4e00\u4e9b\u5f00\u53d1\u5de5\u5177\u548c\u5e93\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum groupinstall -y &quot;Development Tools&quot;<\/p>\n<p>sudo yum install -y 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><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u5f00\u53d1\u5de5\u5177\u548c\u5e93\u5bf9\u4e8e\u7f16\u8bd1Python\u6e90\u7801\u662f\u5fc5\u9700\u7684\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4e0b\u8f7dPython\u6e90\u7801<\/h3>\n<\/p>\n<p><p>\u524d\u5f80Python\u5b98\u65b9\u9875\u9762\uff08<a href=\"https:\/\/www.python.org\/ftp\/python\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E6%9C%80%E6%96%B0%E7%9A%84Python%E7%89%88%E6%9C%AC%E3%80%82%E4%BD%BF%E7%94%A8%60wget%60%E5%91%BD%E4%BB%A4%E4%B8%8B%E8%BD%BD%E6%BA%90%E7%A0%81%E5%8C%85%EF%BC%9A\">https:\/\/www.python.org\/ftp\/python\/\uff09\u4e0b\u8f7d\u6700\u65b0\u7684Python\u7248\u672c\u3002\u4f7f\u7528`wget`\u547d\u4ee4\u4e0b\u8f7d\u6e90\u7801\u5305\uff1a<\/a><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd \/usr\/src<\/p>\n<p>sudo wget https:\/\/www.python.org\/ftp\/python\/3.9.9\/Python-3.9.9.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u89e3\u538b\u7f29\u4e0b\u8f7d\u7684\u6e90\u7801\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo tar xzf Python-3.9.9.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u7f16\u8bd1\u548c\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u8fdb\u5165\u89e3\u538b\u7f29\u540e\u7684\u76ee\u5f55\uff0c\u5e76\u7f16\u8bd1\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd Python-3.9.9<\/p>\n<p>sudo .\/configure --enable-optimizations<\/p>\n<p>sudo make altinstall<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong><code>--enable-optimizations<\/code><\/strong>\u6807\u5fd7\u542f\u7528\u4e00\u4e9b\u989d\u5916\u7684\u4f18\u5316\uff0c\u867d\u7136\u8fd9\u4f1a\u4f7f\u7f16\u8bd1\u65f6\u95f4\u66f4\u957f\uff0c\u4f46\u6700\u7ec8\u7684Python\u89e3\u91ca\u5668\u4f1a\u66f4\u5feb\u3002<\/p>\n<\/p>\n<p><p><strong><code>make altinstall<\/code><\/strong>\u547d\u4ee4\u7528\u6765\u907f\u514d\u8986\u76d6\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u9700\u8981\u5c06\u65b0\u7684Python\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u7f16\u8f91<code>~\/.bashrc<\/code>\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo vi ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/usr\/local\/bin:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u5e76\u9000\u51fa\uff0c\u7136\u540e\u91cd\u65b0\u52a0\u8f7d<code>~\/.bashrc<\/code>\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3.9 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u8fd4\u56de\u4e86\u6b63\u786e\u7684Python\u7248\u672c\u53f7\uff0c\u5219\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5b89\u88c5pip\u548c\u5e38\u7528\u6a21\u5757<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5Python\u540e\uff0c\u901a\u5e38\u9700\u8981\u5b89\u88c5<code>pip<\/code>\u6765\u7ba1\u7406Python\u5305\u3002<code>pip<\/code>\u901a\u5e38\u968fPython\u4e00\u8d77\u5b89\u88c5\uff0c\u4f46\u5982\u679c\u6ca1\u6709\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install -y epel-release<\/p>\n<p>sudo yum install -y python-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u5b89\u88c5\u5e38\u7528\u7684Python\u6a21\u5757\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p>pip install pandas<\/p>\n<p>pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u89e3\u51b3\u5e38\u89c1\u95ee\u9898<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\uff0c\u4f8b\u5982\u7f3a\u5c11\u67d0\u4e9b\u4f9d\u8d56\u9879\u6216\u6743\u9650\u95ee\u9898\u3002\u786e\u4fdd\u4f60\u6709\u8db3\u591f\u7684\u6743\u9650\uff08\u4f7f\u7528<code>sudo<\/code>\uff09\uff0c\u5e76\u4e14\u6240\u6709\u5fc5\u8981\u7684\u5e93\u90fd\u5df2\u5b89\u88c5\u3002\u5982\u679c\u9047\u5230\u6743\u9650\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528<code>sudo<\/code>\u91cd\u65b0\u8fd0\u884c\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u7ba1\u7406\u591a\u7248\u672cPython<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u7ba1\u7406\u591a\u4e2a\u7248\u672c\u7684Python\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528<code>pyenv<\/code>\u6765\u5b9e\u73b0\u3002<code>pyenv<\/code>\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u7248\u672c\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\u548c\u5207\u6362\u4e0d\u540c\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5<code>pyenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">curl https:\/\/pyenv.run | bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\u5230<code>~\/.bashrc<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;$HOME\/.pyenv\/bin:$PATH&quot;<\/p>\n<p>eval &quot;$(pyenv init --path)&quot;<\/p>\n<p>eval &quot;$(pyenv init -)&quot;<\/p>\n<p>eval &quot;$(pyenv virtualenv-init -)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u91cd\u65b0\u52a0\u8f7d<code>~\/.bashrc<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>pyenv<\/code>\u5b89\u88c5\u548c\u7ba1\u7406\u4e0d\u540c\u7248\u672c\u7684Python\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.9.9<\/p>\n<p>pyenv global 3.9.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\uff0c\u5efa\u8bae\u4f7f\u7528Python\u7684\u865a\u62df\u73af\u5883\uff08virtual environment\uff09\u3002\u865a\u62df\u73af\u5883\u5141\u8bb8\u4f60\u5728\u4e00\u4e2a\u9694\u79bb\u7684\u73af\u5883\u4e2d\u5b89\u88c5\u548c\u7ba1\u7406\u5305\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u7cfb\u7edf\u7684\u5176\u4ed6\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5<code>virtualenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">virtualenv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5\u4efb\u4f55\u9700\u8981\u7684\u5305\uff0c\u800c\u8fd9\u4e9b\u5305\u53ea\u4f1a\u5f71\u54cd\u8fd9\u4e2a\u865a\u62df\u73af\u5883\u3002\u8981\u9000\u51fa\u865a\u62df\u73af\u5883\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u4e00\u3001\u81ea\u52a8\u5316\u5b89\u88c5\u811a\u672c<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u5728\u591a\u4e2a\u7cfb\u7edf\u4e0a\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u81ea\u52a8\u5316\u811a\u672c\u6765\u7b80\u5316\u8fd9\u4e2a\u8fc7\u7a0b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">#!\/bin\/bash<\/p>\n<h2><strong>\u66f4\u65b0\u7cfb\u7edf<\/strong><\/h2>\n<p>sudo yum update -y<\/p>\n<h2><strong>\u5b89\u88c5\u5f00\u53d1\u5de5\u5177\u548c\u5e93<\/strong><\/h2>\n<p>sudo yum groupinstall -y &quot;Development Tools&quot;<\/p>\n<p>sudo yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel<\/p>\n<h2><strong>\u4e0b\u8f7d\u5e76\u89e3\u538bPython\u6e90\u7801<\/strong><\/h2>\n<p>cd \/usr\/src<\/p>\n<p>sudo wget https:\/\/www.python.org\/ftp\/python\/3.9.9\/Python-3.9.9.tgz<\/p>\n<p>sudo tar xzf Python-3.9.9.tgz<\/p>\n<h2><strong>\u7f16\u8bd1\u548c\u5b89\u88c5Python<\/strong><\/h2>\n<p>cd Python-3.9.9<\/p>\n<p>sudo .\/configure --enable-optimizations<\/p>\n<p>sudo make altinstall<\/p>\n<h2><strong>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/strong><\/h2>\n<p>echo &#39;export PATH=&quot;\/usr\/local\/bin:$PATH&quot;&#39; &gt;&gt; ~\/.bashrc<\/p>\n<p>source ~\/.bashrc<\/p>\n<h2><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/h2>\n<p>python3.9 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u4e0a\u8ff0\u811a\u672c\u4e3a<code>install_python.sh<\/code>\uff0c\u5e76\u8d4b\u4e88\u6267\u884c\u6743\u9650\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">chmod +x install_python.sh<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u8fd0\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/install_python.sh<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u811a\u672c\u5c06\u81ea\u52a8\u6267\u884c\u6240\u6709\u6b65\u9aa4\uff0c\u4ece\u66f4\u65b0\u7cfb\u7edf\u5230\u9a8c\u8bc1Python\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e8c\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728CentOS 7\u4e0a\u5b89\u88c5Python\u6d89\u53ca\u4e00\u4e9b\u6b65\u9aa4\uff0c\u4f46\u8fd9\u4e9b\u6b65\u9aa4\u76f8\u5bf9\u7b80\u5355\u4e14\u5bb9\u6613\u6267\u884c\u3002\u901a\u8fc7\u786e\u4fdd\u7cfb\u7edf\u66f4\u65b0\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5f00\u53d1\u5de5\u5177\u3001\u4e0b\u8f7d\u548c\u7f16\u8bd1Python\u6e90\u7801\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u4ee5\u53ca\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305\uff0c\u4f60\u53ef\u4ee5\u5728CentOS 7\u4e0a\u6210\u529f\u5b89\u88c5\u5e76\u4f7f\u7528Python\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u548c<code>pyenv<\/code>\u53ef\u4ee5\u8fdb\u4e00\u6b65\u7b80\u5316\u5305\u7ba1\u7406\u548c\u591a\u7248\u672cPython\u7684\u4f7f\u7528\u3002\u5bf9\u4e8e\u9700\u8981\u5728\u591a\u4e2a\u7cfb\u7edf\u4e0a\u91cd\u590d\u5b89\u88c5Python\u7684\u60c5\u51b5\uff0c\u7f16\u5199\u81ea\u52a8\u5316\u811a\u672c\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728CentOS 7\u4e0a\u5b89\u88c5Python\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728CentOS 7\u4e0a\u5b89\u88c5Python\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u5305\u62ec\u4f7f\u7528Yum\u5305\u7ba1\u7406\u5668\u6216\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u3002\u4f7f\u7528Yum\u662f\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\uff1a  <\/p>\n<pre><code>sudo yum install python3\n<\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python3 --version<\/code>\u6765\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728CentOS 7\u4e0a\u540c\u65f6\u5b89\u88c5\u591a\u4e2a\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\u4e3a\u4e86\u5728CentOS 7\u4e0a\u540c\u65f6\u5b89\u88c5\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u5efa\u8bae\u4f7f\u7528<code>pyenv<\/code>\u5de5\u5177\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u4f9d\u8d56\u9879\uff0c\u7136\u540e\u901a\u8fc7<code>curl<\/code>\u6216<code>git<\/code>\u83b7\u53d6<code>pyenv<\/code>\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>pyenv install<\/code>\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684Python\u7248\u672c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>pyenv install 3.8.10\npyenv install 3.9.5\n<\/code><\/pre>\n<p>\u5b89\u88c5\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pyenv global<\/code>\u6216<code>pyenv local<\/code>\u547d\u4ee4\u8bbe\u7f6e\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002<\/p>\n<p><strong>\u5728CentOS 7\u4e0a\u5b89\u88c5Python\u540e\uff0c\u5982\u4f55\u7ba1\u7406Python\u5305\uff1f<\/strong><br \/>\u5b89\u88c5Python\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u6765\u7ba1\u7406Python\u5305\u3002<code>pip<\/code>\u901a\u5e38\u4f1a\u4e0ePython\u4e00\u8d77\u5b89\u88c5\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684\u5305\uff1a<\/p>\n<pre><code>pip install package_name\n<\/code><\/pre>\n<p>\u5982\u679c\u60a8\u9700\u8981\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u7684\u4f9d\u8d56\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<code>virtualenv<\/code>\u6765\u521b\u5efa\u9694\u79bb\u7684Python\u73af\u5883\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u5e93\u51b2\u7a81\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5<code>virtualenv<\/code>\uff1a<\/p>\n<pre><code>pip install virtualenv\n<\/code><\/pre>\n<p>\u521b\u5efa\u65b0\u7684\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u4e3a\uff1a<\/p>\n<pre><code>virtualenv myenv\n<\/code><\/pre>\n<p>\u6fc0\u6d3b\u8be5\u73af\u5883\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u81ea\u7531\u5b89\u88c5\u548c\u7ba1\u7406\u4f9d\u8d56\u5305\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728CentOS 7\u4e0a\u4e0b\u8f7d\u5b89\u88c5Python\u6d89\u53ca\u51e0\u4e2a\u6b65\u9aa4\uff1a\u786e\u4fdd\u7cfb\u7edf\u66f4\u65b0\u3001\u5b89\u88c5\u5f00\u53d1\u5de5\u5177\u3001\u4e0b\u8f7dPython\u6e90\u7801\u3001\u7f16\u8bd1\u548c [&hellip;]","protected":false},"author":3,"featured_media":1075665,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1075657"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1075657"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1075657\/revisions"}],"predecessor-version":[{"id":1075666,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1075657\/revisions\/1075666"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1075665"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1075657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1075657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1075657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}