{"id":1054942,"date":"2024-12-31T14:46:29","date_gmt":"2024-12-31T06:46:29","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1054942.html"},"modified":"2024-12-31T14:46:31","modified_gmt":"2024-12-31T06:46:31","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8linux%e4%b8%8b%e5%ae%89%e8%a3%85python3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1054942.html","title":{"rendered":"\u5982\u4f55\u5728linux\u4e0b\u5b89\u88c5python3"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/8e0b77f2-3475-4167-b2d2-d24124c90814.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u5728linux\u4e0b\u5b89\u88c5python3\" \/><\/p>\n<p><p> <strong>\u5728Linux\u4e0b\u5b89\u88c5Python3\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u3001\u6e90\u7801\u5b89\u88c5\u3001\u4ee5\u53ca\u4f7f\u7528\u5de5\u5177\u5982pyenv\u3002<\/strong><\/p>\n<\/p>\n<p><p><strong>\u5305\u7ba1\u7406\u5668\u4fbf\u6377\u3001\u6e90\u7801\u5b89\u88c5\u7075\u6d3b\u3001pyenv\u9002\u5408\u591a\u7248\u672c\u7ba1\u7406<\/strong>\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u5404\u6709\u4f18\u7f3a\u70b9\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u51e0\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u5305\u7ba1\u7406\u5668\u5b89\u88c5<\/h2>\n<\/p>\n<p><h3>1. \u4f7f\u7528apt-get\uff08\u9002\u7528\u4e8eDebian\u548cUbuntu\uff09<\/h3>\n<\/p>\n<p><h4>\u66f4\u65b0\u5305\u5217\u8868<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u66f4\u65b0\u5305\u5217\u8868\u4ee5\u786e\u4fdd\u83b7\u53d6\u6700\u65b0\u7684\u8f6f\u4ef6\u5305\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5b89\u88c5Python3<\/h4>\n<\/p>\n<p><p>\u63a5\u7740\uff0c\u5b89\u88c5Python3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u9a8c\u8bc1\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528yum\uff08\u9002\u7528\u4e8eCentOS\u548cRedHat\uff09<\/h3>\n<\/p>\n<p><h4>\u66f4\u65b0\u5305\u5217\u8868<\/h4>\n<\/p>\n<p><p>\u66f4\u65b0\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5b89\u88c5Python3<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5Python3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u9a8c\u8bc1\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u9a8c\u8bc1Python3\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3. \u4f7f\u7528dnf\uff08\u9002\u7528\u4e8eFedora\uff09<\/h3>\n<\/p>\n<p><h4>\u66f4\u65b0\u5305\u5217\u8868<\/h4>\n<\/p>\n<p><p>\u66f4\u65b0\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo dnf update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5b89\u88c5Python3<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5Python3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo dnf install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u9a8c\u8bc1\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u9a8c\u8bc1Python3\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e8c\u3001\u6e90\u7801\u5b89\u88c5<\/h2>\n<\/p>\n<p><p>\u6e90\u7801\u5b89\u88c5\u65b9\u6cd5\u901a\u5e38\u9002\u7528\u4e8e\u9700\u8981\u81ea\u5b9a\u4e49\u5b89\u88c5\u8fc7\u7a0b\u6216\u5728\u5305\u7ba1\u7406\u5668\u4e2d\u6ca1\u6709\u6700\u65b0\u7248\u672c\u7684\u60c5\u51b5\u3002\u6b64\u65b9\u6cd5\u867d\u7136\u7075\u6d3b\uff0c\u4f46\u8f83\u4e3a\u590d\u6742\u3002<\/p>\n<\/p>\n<p><h3>1. \u4e0b\u8f7d\u6e90\u7801<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6240\u9700\u7248\u672c\u7684\u6e90\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">wget https:\/\/www.python.org\/ftp\/python\/3.x.y\/Python-3.x.y.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x.y<\/code>\u66ff\u6362\u4e3a\u4f60\u60f3\u8981\u5b89\u88c5\u7684\u5177\u4f53\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><h3>2. \u89e3\u538b\u6e90\u7801<\/h3>\n<\/p>\n<p><p>\u89e3\u538b\u4e0b\u8f7d\u7684\u6e90\u7801\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">tar -xvf Python-3.x.y.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3. \u914d\u7f6e\u548c\u7f16\u8bd1<\/h3>\n<\/p>\n<p><p>\u8fdb\u5165\u89e3\u538b\u540e\u7684\u6e90\u7801\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd Python-3.x.y<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u914d\u7f6e\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/configure --enable-optimizations<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u8bd1\u6e90\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">make<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4. \u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u7f16\u8bd1\u597d\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo make altinstall<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6ce8\u610f\uff1a\u4f7f\u7528<code>altinstall<\/code>\u800c\u4e0d\u662f<code>install<\/code>\uff0c\u4ee5\u907f\u514d\u8986\u76d6\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>5. \u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3.x --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x<\/code>\u66ff\u6362\u4e3a\u5177\u4f53\u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528pyenv<\/h2>\n<\/p>\n<p><p>pyenv\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>1. \u5b89\u88c5\u4f9d\u8d56<\/h3>\n<\/p>\n<p><p>\u5728\u5b89\u88c5pyenv\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u4f9d\u8d56\u5305\uff1a<\/p>\n<\/p>\n<p><h4>Debian\/Ubuntu\uff1a<\/h4>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get update<\/p>\n<p>sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \\<\/p>\n<p>libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \\<\/p>\n<p>libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev \\<\/p>\n<p>liblzma-dev python-openssl git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>CentOS\/Fedora\uff1a<\/h4>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install gcc zlib-devel bzip2 bzip2-devel readline-devel \\<\/p>\n<p>sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel \\<\/p>\n<p>git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u5b89\u88c5pyenv<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528curl\u5b89\u88c5pyenv\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><h3>3. \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u5230\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\uff08\u4f8b\u5982<code>~\/.bashrc<\/code>\u6216<code>~\/.zshrc<\/code>\uff09\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>\u7136\u540e\uff0c\u91cd\u65b0\u52a0\u8f7dshell\u914d\u7f6e\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>4. \u5b89\u88c5Python\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u6240\u9700\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.x.y<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x.y<\/code>\u66ff\u6362\u4e3a\u5177\u4f53\u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><h3>5. \u8bbe\u7f6e\u5168\u5c40Python\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u8bbe\u7f6e\u5168\u5c40\u4f7f\u7528\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv global 3.x.y<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>6. \u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p><strong>\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u4fbf\u6377\u9002\u5408\u5927\u591a\u6570\u60c5\u51b5\u3001\u6e90\u7801\u5b89\u88c5\u7075\u6d3b\u4f46\u590d\u6742\u3001pyenv\u9002\u5408\u591a\u7248\u672c\u7ba1\u7406<\/strong>\u3002\u6839\u636e\u4f60\u7684\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u5305\u7ba1\u7406\u5668\u7684\u4f18\u7f3a\u70b9<\/h3>\n<\/p>\n<p><p>\u5305\u7ba1\u7406\u5668\u5b89\u88c5Python3\u7684\u65b9\u6cd5\u975e\u5e38\u4fbf\u6377\uff0c\u9002\u5408\u5927\u591a\u6570\u60c5\u51b5\u3002\u5b83\u7684\u4f18\u70b9\u662f\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u7b80\u5355\u5feb\u6377<\/strong>\uff1a\u53ea\u9700\u51e0\u6761\u547d\u4ee4\u5373\u53ef\u5b8c\u6210\u5b89\u88c5\u3002<\/li>\n<li><strong>\u4f9d\u8d56\u7ba1\u7406<\/strong>\uff1a\u5305\u7ba1\u7406\u5668\u4f1a\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u4e86\u624b\u52a8\u5b89\u88c5\u4f9d\u8d56\u7684\u9ebb\u70e6\u3002<\/li>\n<li><strong>\u66f4\u65b0\u65b9\u4fbf<\/strong>\uff1a\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u8f7b\u677e\u66f4\u65b0\u5230\u6700\u65b0\u7684Python\u7248\u672c\u3002<\/li>\n<\/ul>\n<p><p>\u7136\u800c\uff0c\u8fd9\u79cd\u65b9\u6cd5\u4e5f\u6709\u4e00\u4e9b\u7f3a\u70b9\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u7248\u672c\u9650\u5236<\/strong>\uff1a\u5305\u7ba1\u7406\u5668\u4e2d\u7684Python\u7248\u672c\u53ef\u80fd\u4e0d\u662f\u6700\u65b0\u7684\uff0c\u5c24\u5176\u662f\u5728\u4e00\u4e9bLTS\uff08\u957f\u671f\u652f\u6301\uff09\u7248\u672c\u7684\u53d1\u884c\u7248\u4e2d\u3002<\/li>\n<li><strong>\u5b9a\u5236\u6027\u5dee<\/strong>\uff1a\u65e0\u6cd5\u5bf9\u5b89\u88c5\u8fc7\u7a0b\u8fdb\u884c\u592a\u591a\u5b9a\u5236\uff0c\u9002\u7528\u4e8e\u6807\u51c6\u9700\u6c42\uff0c\u4f46\u5bf9\u4e8e\u4e00\u4e9b\u7279\u6b8a\u9700\u6c42\u53ef\u80fd\u4e0d\u592a\u5408\u9002\u3002<\/li>\n<\/ul>\n<p><h3>\u6e90\u7801\u5b89\u88c5\u7684\u4f18\u7f3a\u70b9<\/h3>\n<\/p>\n<p><p>\u6e90\u7801\u5b89\u88c5Python3\u7684\u65b9\u6cd5\u867d\u7136\u8f83\u4e3a\u590d\u6742\uff0c\u4f46\u63d0\u4f9b\u4e86\u6700\u5927\u7684\u7075\u6d3b\u6027\u3002\u5176\u4f18\u70b9\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u7075\u6d3b\u6027\u9ad8<\/strong>\uff1a\u53ef\u4ee5\u5bf9\u5b89\u88c5\u8fc7\u7a0b\u8fdb\u884c\u9ad8\u5ea6\u5b9a\u5236\uff0c\u9009\u62e9\u7f16\u8bd1\u9009\u9879\u3001\u5b89\u88c5\u8def\u5f84\u7b49\u3002<\/li>\n<li><strong>\u6700\u65b0\u7248\u672c<\/strong>\uff1a\u53ef\u4ee5\u76f4\u63a5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684\u6e90\u7801\u8fdb\u884c\u5b89\u88c5\uff0c\u786e\u4fdd\u4f7f\u7528\u6700\u524d\u6cbf\u7684\u529f\u80fd\u548c\u4fee\u590d\u3002<\/li>\n<\/ul>\n<p><p>\u4f46\u8fd9\u79cd\u65b9\u6cd5\u4e5f\u6709\u4e00\u4e9b\u7f3a\u70b9\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u590d\u6742\u5ea6\u9ad8<\/strong>\uff1a\u9700\u8981\u624b\u52a8\u5904\u7406\u4f9d\u8d56\u548c\u7f16\u8bd1\u8fc7\u7a0b\uff0c\u9002\u5408\u6709\u4e00\u5b9aLinux\u4f7f\u7528\u7ecf\u9a8c\u7684\u7528\u6237\u3002<\/li>\n<li><strong>\u65f6\u95f4\u8f83\u957f<\/strong>\uff1a\u7f16\u8bd1\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u8f83\u957f\u65f6\u95f4\uff0c\u5c24\u5176\u662f\u5728\u786c\u4ef6\u6027\u80fd\u8f83\u4f4e\u7684\u60c5\u51b5\u4e0b\u3002<\/li>\n<\/ul>\n<p><h3>pyenv\u7684\u4f18\u7f3a\u70b9<\/h3>\n<\/p>\n<p><p>pyenv\u662f\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u7684Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u7279\u522b\u9002\u5408\u9700\u8981\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u7684\u5f00\u53d1\u8005\u3002\u5176\u4f18\u70b9\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u591a\u7248\u672c\u7ba1\u7406<\/strong>\uff1a\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\u548c\u5207\u6362\u591a\u4e2aPython\u7248\u672c\uff0c\u9002\u5408\u5f00\u53d1\u548c\u6d4b\u8bd5\u4e0d\u540c\u7248\u672c\u7684\u9700\u6c42\u3002<\/li>\n<li><strong>\u9694\u79bb\u73af\u5883<\/strong>\uff1a\u6bcf\u4e2aPython\u7248\u672c\u548c\u5176\u4f9d\u8d56\u5e93\u90fd\u53ef\u4ee5\u72ec\u7acb\u7ba1\u7406\uff0c\u907f\u514d\u4e86\u7248\u672c\u51b2\u7a81\u3002<\/li>\n<li><strong>\u4fbf\u6377\u6027<\/strong>\uff1a\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u547d\u4ee4\u884c\u63a5\u53e3\uff0c\u6613\u4e8e\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p><p>\u4f46pyenv\u4e5f\u6709\u4e00\u4e9b\u7f3a\u70b9\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u521d\u59cb\u914d\u7f6e\u590d\u6742<\/strong>\uff1a\u521d\u6b21\u5b89\u88c5\u548c\u914d\u7f6epyenv\u53ef\u80fd\u9700\u8981\u4e00\u5b9a\u65f6\u95f4\uff0c\u5c24\u5176\u662f\u5bf9\u65b0\u624b\u7528\u6237\u6765\u8bf4\u3002<\/li>\n<li><strong>\u6027\u80fd\u5f00\u9500<\/strong>\uff1a\u7531\u4e8e\u4f7f\u7528\u4e86shims\u548c\u73af\u5883\u53d8\u91cf\uff0c\u53ef\u80fd\u5bf9\u6027\u80fd\u6709\u4e00\u4e9b\u5fae\u5c0f\u7684\u5f71\u54cd\u3002<\/li>\n<\/ul>\n<p><h3>\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u5b89\u88c5Python3\u7684\u65b9\u6cd5\u65f6\uff0c\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\u548c\u81ea\u8eab\u60c5\u51b5\u6765\u51b3\u5b9a\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5982\u679c\u4f60\u662f\u666e\u901a\u7528\u6237\uff0c\u4e14\u53ea\u9700\u8981\u4e00\u4e2a\u7a33\u5b9a\u7684Python\u7248\u672c<\/strong>\uff0c\u63a8\u8350\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\uff0c\u56e0\u4e3a\u8fd9\u79cd\u65b9\u6cd5\u6700\u4e3a\u7b80\u5355\u5feb\u6377\u3002<\/li>\n<li><strong>\u5982\u679c\u4f60\u9700\u8981\u6700\u65b0\u7248\u672c\u7684Python\uff0c\u4e14\u613f\u610f\u82b1\u65f6\u95f4\u8fdb\u884c\u914d\u7f6e\u548c\u7f16\u8bd1<\/strong>\uff0c\u53ef\u4ee5\u9009\u62e9\u6e90\u7801\u5b89\u88c5\uff0c\u4ee5\u83b7\u53d6\u6700\u5927\u7684\u7075\u6d3b\u6027\u3002<\/li>\n<li><strong>\u5982\u679c\u4f60\u662f\u5f00\u53d1\u8005\uff0c\u4e14\u9700\u8981\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c<\/strong>\uff0cpyenv\u662f\u4e00\u4e2a\u975e\u5e38\u4f18\u79c0\u7684\u9009\u62e9\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u7248\u672c\u5207\u6362\u548c\u73af\u5883\u9694\u79bb\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6cd5\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u76f8\u4fe1\u4f60\u5df2\u7ecf\u80fd\u591f\u5728Linux\u4e0b\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\uff0c\u9009\u62e9\u6700\u5408\u9002\u7684\u65b9\u5f0f\u5b89\u88c5Python3\u3002\u65e0\u8bba\u662f\u5305\u7ba1\u7406\u5668\u7684\u4fbf\u6377\uff0c\u6e90\u7801\u5b89\u88c5\u7684\u7075\u6d3b\uff0c\u8fd8\u662fpyenv\u7684\u591a\u7248\u672c\u7ba1\u7406\uff0c\u90fd\u53ef\u4ee5\u5e2e\u52a9\u4f60\u987a\u5229\u5b8c\u6210Python3\u7684\u5b89\u88c5\uff0c\u4e3a\u540e\u7eed\u7684\u5f00\u53d1\u5de5\u4f5c\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Linux\u4e0b\u5b89\u88c5Python3\u9700\u8981\u54ea\u4e9b\u6b65\u9aa4\uff1f<\/strong><br \/>\u5728Linux\u7cfb\u7edf\u4e2d\u5b89\u88c5Python3\u901a\u5e38\u6d89\u53ca\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff0c\u4ee5\u786e\u4fdd\u60a8\u83b7\u53d6\u7684\u662f\u6700\u65b0\u7248\u672c\u7684\u8f6f\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982apt\u3001yum\u6216dnf\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5Python3\u3002\u5bf9\u4e8eDebian\u548cUbuntu\u7cfb\u7edf\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<code>sudo apt install python3<\/code>\u3002\u800c\u5bf9\u4e8eRed Hat\u6216CentOS\u7cfb\u7edf\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528<code>sudo yum install python3<\/code>\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u8f93\u5165<code>python3 --version<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u6211\u9700\u6c42\u7684Python3\u7248\u672c\uff1f<\/strong><br \/>\u9009\u62e9Python3\u7684\u7248\u672c\u901a\u5e38\u53d6\u51b3\u4e8e\u60a8\u7684\u9879\u76ee\u9700\u6c42\u548c\u517c\u5bb9\u6027\u3002\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u63a8\u8350\u4f7f\u7528\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\uff0c\u56e0\u4e3a\u5b83\u5305\u542b\u4e86\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u4fee\u590d\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u76f4\u63a5\u5b89\u88c5\u6700\u65b0\u7248\u672c\uff0c\u6216\u8005\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6e90\u4ee3\u7801\u8fdb\u884c\u81ea\u5b9a\u4e49\u5b89\u88c5\u3002\u5982\u679c\u60a8\u9700\u8981\u7279\u5b9a\u7248\u672c\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u7248\u672c\u7ba1\u7406\u5de5\u5177\u5982pyenv\u6765\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<p><strong>\u5728Linux\u4e0a\u5b89\u88c5Python3\u540e\uff0c\u5982\u4f55\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1f<\/strong><br \/>\u5b89\u88c5Python3\u540e\uff0c\u53ef\u80fd\u9700\u8981\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u5728\u4efb\u4f55\u4f4d\u7f6e\u90fd\u53ef\u4ee5\u8fd0\u884cPython\u547d\u4ee4\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>~\/.bashrc<\/code>\u6216<code>~\/.bash_profile<\/code>\u6587\u4ef6\u6765\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u6253\u5f00\u6587\u4ef6\u540e\uff0c\u6dfb\u52a0\u5982\u4e0b\u884c\uff1a<code>export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/code>\uff0c\u7136\u540e\u4f7f\u7528<code>source ~\/.bashrc<\/code>\u547d\u4ee4\u4f7f\u66f4\u6539\u751f\u6548\u3002\u8fd9\u6837\uff0c\u60a8\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u76f4\u63a5\u4f7f\u7528<code>python3<\/code>\u547d\u4ee4\uff0c\u800c\u65e0\u9700\u8f93\u5165\u5b8c\u6574\u8def\u5f84\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u4e0b\u5b89\u88c5Python3\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u3001\u6e90\u7801\u5b89\u88c5\u3001\u4ee5\u53ca\u4f7f\u7528\u5de5\u5177\u5982pyenv\u3002 \u5305\u7ba1\u7406\u5668 [&hellip;]","protected":false},"author":3,"featured_media":1054953,"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\/1054942"}],"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=1054942"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1054942\/revisions"}],"predecessor-version":[{"id":1054956,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1054942\/revisions\/1054956"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1054953"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1054942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1054942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1054942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}