{"id":975772,"date":"2024-12-27T06:16:04","date_gmt":"2024-12-26T22:16:04","guid":{"rendered":""},"modified":"2024-12-27T06:16:06","modified_gmt":"2024-12-26T22:16:06","slug":"linux%e5%a6%82%e4%bd%95python3-5","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/975772.html","title":{"rendered":"linux\u5982\u4f55python3.5"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24200845\/e322a859-9a5d-48a1-9b25-2fa3a25fde2c.webp\" alt=\"linux\u5982\u4f55python3.5\" \/><\/p>\n<p><p> <strong>\u5728Linux\u4e0a\u5b89\u88c5Python 3.5\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\u3001\u4f7f\u7528pyenv\u8fdb\u884c\u7248\u672c\u7ba1\u7406\u3002<\/strong>\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5728Linux\u7cfb\u7edf\u4e0a\u901a\u8fc7\u8fd9\u51e0\u79cd\u65b9\u6cd5\u6765\u5b89\u88c5Python 3.5\uff0c\u5e76\u89e3\u91ca\u6bcf\u79cd\u65b9\u6cd5\u7684\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5Python 3.5<\/p>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5\u8f6f\u4ef6\u662f\u6700\u5e38\u89c1\u548c\u4fbf\u6377\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u4f7f\u7528\u4e0d\u540c\u7684\u5305\u7ba1\u7406\u5668\uff0c\u5982Ubuntu\u4f7f\u7528apt\uff0cFedora\u4f7f\u7528dnf\u6216yum\uff0cArch Linux\u4f7f\u7528pacman\u7b49\u3002\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5Python 3.5\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u66f4\u65b0\u8f6f\u4ef6\u5305\u4fe1\u606f<\/strong><br \/>\u5728\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u8f6f\u4ef6\u5305\u4fe1\u606f\u662f\u6700\u65b0\u7684\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update   # \u5bf9\u4e8eDebian\u548cUbuntu<\/p>\n<p>sudo yum update   # \u5bf9\u4e8eCentOS\u548cRHEL<\/p>\n<p>sudo dnf update   # \u5bf9\u4e8eFedora<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5Python 3.5\u662f\u5426\u53ef\u7528<\/strong><br \/>\u6709\u4e9b\u53d1\u884c\u7248\u7684\u9ed8\u8ba4\u8f6f\u4ef6\u6e90\u53ef\u80fd\u5df2\u7ecf\u4e0d\u518d\u63d0\u4f9bPython 3.5\u7684\u5b89\u88c5\u5305\uff0c\u56e0\u6b64\u9700\u8981\u68c0\u67e5\u662f\u5426\u53ef\u4ee5\u76f4\u63a5\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">apt-cache policy python3.5   # \u5bf9\u4e8eDebian\u548cUbuntu<\/p>\n<p>yum list python3.5           # \u5bf9\u4e8eCentOS\u548cRHEL<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python 3.5<\/strong><br \/>\u5982\u679c\u5305\u53ef\u7528\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt install python3.5   # \u5bf9\u4e8eDebian\u548cUbuntu<\/p>\n<p>sudo yum install python3.5   # \u5bf9\u4e8eCentOS\u548cRHEL<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u7684\u4f18\u70b9\u662f\u7b80\u4fbf\u6613\u884c\uff0c\u4e14\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\u3002\u7136\u800c\uff0c\u7531\u4e8ePython 3.5\u5df2\u7ecf\u8f83\u4e3a\u8fc7\u65f6\uff0c\u4e00\u4e9bLinux\u53d1\u884c\u7248\u7684\u9ed8\u8ba4\u8f6f\u4ef6\u6e90\u53ef\u80fd\u4e0d\u518d\u63d0\u4f9b\u5b83\u3002\u56e0\u6b64\uff0c\u53ef\u80fd\u9700\u8981\u6dfb\u52a0\u7b2c\u4e09\u65b9\u6e90\u6216\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5Python 3.5<\/p>\n<\/p>\n<p><p>\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5Python 3.5\u662f\u4e00\u79cd\u901a\u7528\u4e14\u7075\u6d3b\u7684\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u6240\u6709Linux\u53d1\u884c\u7248\u3002\u8fd9\u79cd\u65b9\u6cd5\u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49Python\u7684\u7f16\u8bd1\u9009\u9879\uff0c\u4f46\u4e5f\u9700\u8981\u66f4\u591a\u7684\u6b65\u9aa4\u548c\u65f6\u95f4\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56\u5de5\u5177<\/strong><br \/>\u7f16\u8bd1Python\u9700\u8981\u4e00\u4e9b\u57fa\u672c\u7684\u6784\u5efa\u5de5\u5177\u548c\u5e93\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt install build-essential libssl-dev libffi-dev zlib1g-dev  # Debian\u548cUbuntu<\/p>\n<p>sudo yum groupinstall &quot;Development Tools&quot; &amp;&amp; sudo yum install openssl-devel bzip2-devel libffi-devel  # CentOS\u548cRHEL<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7dPython 3.5\u6e90\u4ee3\u7801<\/strong><br \/>\u53ef\u4ee5\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7dPython 3.5\u7684\u6e90\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">wget https:\/\/www.python.org\/ftp\/python\/3.5.10\/Python-3.5.10.tgz<\/p>\n<p>tar -xvf Python-3.5.10.tgz<\/p>\n<p>cd Python-3.5.10<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8bd1\u548c\u5b89\u88c5<\/strong><br \/>\u914d\u7f6e\u7f16\u8bd1\u73af\u5883\u5e76\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/configure --enable-optimizations<\/p>\n<p>make -j 4  # \u4f7f\u7528\u591a\u4e2a\u5185\u6838\u8fdb\u884c\u7f16\u8bd1\uff0c\u52a0\u5feb\u901f\u5ea6<\/p>\n<p>sudo make altinstall  # \u4f7f\u7528altinstall\u9632\u6b62\u8986\u76d6\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u7248\u672c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u7075\u6d3b\uff0c\u53ef\u4ee5\u5728\u4efb\u4f55Linux\u7cfb\u7edf\u4e0a\u5b9e\u73b0\u3002\u4f46\u7f3a\u70b9\u662f\u9700\u8981\u624b\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\u548c\u66f4\u65b0\u7ef4\u62a4\u76f8\u5bf9\u590d\u6742\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528pyenv\u8fdb\u884c\u7248\u672c\u7ba1\u7406<\/p>\n<\/p>\n<p><p>pyenv\u662f\u4e00\u6b3e\u7528\u4e8e\u7ba1\u7406Python\u7248\u672c\u7684\u5de5\u5177\uff0c\u5141\u8bb8\u7528\u6237\u5728\u540c\u4e00\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u5207\u6362\u591a\u4e2aPython\u7248\u672c\uff0c\u662f\u5f00\u53d1\u8005\u7684\u5e38\u7528\u5de5\u5177\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5pyenv<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7Git\u514b\u9686\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><p>\u6309\u7167\u63d0\u793a\u914d\u7f6eshell\u73af\u5883\uff0c\u901a\u5e38\u9700\u8981\u5728<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\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 virtualenv-init -)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python 3.5<\/strong><br \/>\u4f7f\u7528pyenv\u5b89\u88c5Python 3.5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.5.10<\/p>\n<p>pyenv global 3.5.10  # \u8bbe\u7f6e\u5168\u5c40\u4f7f\u7528\u7684Python\u7248\u672c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5207\u6362Python\u7248\u672c<\/strong><br \/>\u53ef\u4ee5\u968f\u65f6\u5207\u6362Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv global 3.8.0  # \u5207\u6362\u5230\u53e6\u4e00\u4e2a\u7248\u672c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4f7f\u7528pyenv\u7684\u4f18\u70b9\u662f\u65b9\u4fbf\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u4e0d\u4f1a\u5f71\u54cd\u7cfb\u7edf\u7684\u9ed8\u8ba4Python\u73af\u5883\uff0c\u975e\u5e38\u9002\u5408\u5f00\u53d1\u4eba\u5458\u3002\u7136\u800c\uff0cpyenv\u53ef\u80fd\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e0a\u9700\u8981\u989d\u5916\u7684\u914d\u7f6e\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Linux\u4e0a\u5b89\u88c5Python 3.5\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4f9b\u9009\u62e9\u3002\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u662f\u6700\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u4f46\u53ef\u80fd\u9762\u4e34\u8f6f\u4ef6\u6e90\u4e0d\u518d\u63d0\u4f9b\u65e7\u7248\u672c\u7684\u95ee\u9898\u3002\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\u5219\u63d0\u4f9b\u4e86\u7075\u6d3b\u6027\uff0c\u4f46\u9700\u8981\u66f4\u591a\u65f6\u95f4\u548c\u6b65\u9aa4\u3002\u4f7f\u7528pyenv\u662f\u5f00\u53d1\u8005\u7ba1\u7406\u591a\u7248\u672cPython\u7684\u7406\u60f3\u9009\u62e9\uff0c\u80fd\u591f\u8f7b\u677e\u5207\u6362\u548c\u7ba1\u7406Python\u7248\u672c\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\u548c\u7cfb\u7edf\u73af\u5883\uff0c\u9009\u62e9\u6700\u5408\u9002\u7684\u65b9\u6cd5\u6765\u5b89\u88c5Python 3.5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Linux\u4e0a\u5b89\u88c5Python 3.5\uff1f<\/strong><br \/>\u5728Linux\u4e0a\u5b89\u88c5Python 3.5\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b8c\u6210\u3002\u5bf9\u4e8e\u57fa\u4e8eDebian\u7684\u7cfb\u7edf\uff08\u5982Ubuntu\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a  <\/p>\n<pre><code class=\"language-bash\">sudo apt-get update\nsudo apt-get install python3.5\n<\/code><\/pre>\n<p>\u5bf9\u4e8e\u57fa\u4e8eRed Hat\u7684\u7cfb\u7edf\uff08\u5982CentOS\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a  <\/p>\n<pre><code class=\"language-bash\">sudo yum install python35\n<\/code><\/pre>\n<p>\u5982\u679c\u7cfb\u7edf\u7684\u8f6f\u4ef6\u5e93\u4e0d\u652f\u6301Python 3.5\uff0c\u53ef\u4ee5\u8003\u8651\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\uff0c\u9996\u5148\u9700\u8981\u4e0b\u8f7d\u6e90\u4ee3\u7801\u5305\uff0c\u7136\u540e\u89e3\u538b\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a  <\/p>\n<pre><code class=\"language-bash\">.\/configure\nmake\nsudo make install\n<\/code><\/pre>\n<p><strong>\u5728Linux\u4e2d\u5982\u4f55\u9a8c\u8bc1Python 3.5\u7684\u5b89\u88c5\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1Python 3.5\u662f\u5426\u6210\u529f\u5b89\u88c5\uff1a  <\/p>\n<pre><code class=\"language-bash\">python3.5 --version\n<\/code><\/pre>\n<p>\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u7cfb\u7edf\u5c06\u663e\u793aPython 3.5\u7684\u7248\u672c\u4fe1\u606f\u3002\u6b64\u5916\uff0c\u4e5f\u53ef\u4ee5\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u73af\u5883\uff0c\u8f93\u5165<code>python3.5<\/code>\uff0c\u7136\u540e\u56de\u8f66\u3002\u5982\u679c\u770b\u5230Python\u63d0\u793a\u7b26\uff08\u5982<code>&gt;&gt;&gt;<\/code>\uff09\uff0c\u8bf4\u660ePython 3.5\u5df2\u6b63\u786e\u5b89\u88c5\u3002<\/p>\n<p><strong>Python 3.5\u5728Linux\u4e2d\u7684\u5e38\u89c1\u7528\u9014\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>Python 3.5\u5728Linux\u7cfb\u7edf\u4e2d\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u5b83\u5e38\u7528\u4e8e\u6570\u636e\u5206\u6790\u3001\u81ea\u52a8\u5316\u811a\u672c\u7f16\u5199\u3001Web\u5f00\u53d1\u548c\u79d1\u5b66\u8ba1\u7b97\u7b49\u9886\u57df\u3002\u4f7f\u7528Python\u7684\u4e30\u5bcc\u5e93\uff08\u5982NumPy\u3001Pandas\u548cFlask\u7b49\uff09\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u590d\u6742\u7684\u529f\u80fd\u3002\u540c\u65f6\uff0cPython 3.5\u652f\u6301\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff0c\u4f7f\u5f97\u5f00\u53d1\u5927\u578b\u5e94\u7528\u7a0b\u5e8f\u65f6\u66f4\u52a0\u9ad8\u6548\u3002\u5bf9\u4e8e\u5b66\u4e60\u8005\u6765\u8bf4\uff0c\u5b83\u4e5f\u662f\u4e00\u79cd\u7b80\u5355\u6613\u5b66\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u975e\u5e38\u9002\u5408\u7f16\u5199\u5c0f\u578b\u9879\u76ee\u6216\u8fdb\u884c\u5b66\u4e60\u5b9e\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u4e0a\u5b89\u88c5Python 3.5\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\u3001\u4f7f\u7528pyenv\u8fdb\u884c\u7248\u672c\u7ba1 [&hellip;]","protected":false},"author":3,"featured_media":975774,"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\/975772"}],"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=975772"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/975772\/revisions"}],"predecessor-version":[{"id":975775,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/975772\/revisions\/975775"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/975774"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=975772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=975772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=975772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}