{"id":176673,"date":"2024-05-08T19:15:27","date_gmt":"2024-05-08T11:15:27","guid":{"rendered":""},"modified":"2024-05-08T19:15:33","modified_gmt":"2024-05-08T11:15:33","slug":"%e5%9c%a8ubuntu%e7%b3%bb%e7%bb%9f%e4%b8%8b%e6%80%8e%e4%b9%88%e5%88%87%e6%8d%a2python%e7%9a%84%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/176673.html","title":{"rendered":"\u5728Ubuntu\u7cfb\u7edf\u4e0b\u600e\u4e48\u5207\u6362Python\u7684\u7248\u672c"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27060414\/ea45a714-920f-4f06-aa55-a7ea17ee5e1c.webp\" alt=\"\u5728Ubuntu\u7cfb\u7edf\u4e0b\u600e\u4e48\u5207\u6362Python\u7684\u7248\u672c\" \/><\/p>\n<p><p>\u4f7f\u7528\u591a\u7248\u672c\u7684Python\u7684\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a<strong>\u5728Ubuntu\u7cfb\u7edf\u4e0b\u5207\u6362Python\u7248\u672c<\/strong>\u3001<strong>\u4f7f\u7528update-alternatives\u5de5\u5177\u914d\u7f6ePython\u7248\u672c<\/strong>\u3001<strong>\u5229\u7528pyenv\u8fdb\u884c\u7248\u672c\u7ba1\u7406<\/strong>\u3002\u6211\u4eec\u53ef\u4ee5\u501f\u52a9update-alternatives\u547d\u4ee4\u6765\u914d\u7f6e\u9ed8\u8ba4\u7684Python\u89e3\u91ca\u5668\uff0c\u6216\u8005\u4f7f\u7528\u66f4\u4e13\u4e1a\u7684\u5de5\u5177\u5982pyenv\u6765\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u5e76\u6839\u636e\u9700\u8981\u7075\u6d3b\u5730\u5728\u5b83\u4eec\u4e4b\u95f4\u5207\u6362\u3002\u5728\u6211\u4eec\u7740\u91cd\u4ecb\u7ecdupdate-alternatives\u65b9\u6cd5\u65f6\uff0c\u4e86\u89e3\u5176\u5982\u4f55\u901a\u8fc7Ubuntu\u7684\u66ff\u4ee3\u7cfb\u7edf\u6765\u7ba1\u7406\u4e0d\u540c\u7684\u7a0b\u5e8f\u7248\u672c\u5bf9\u4e8e\u7406\u89e3Python\u7248\u672c\u5207\u6362\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u7406\u89e3Ubuntu\u4e0bPython\u7684\u7248\u672c\u95ee\u9898<\/h3>\n<\/p>\n<p><p>Python\u4f5c\u4e3a\u4e00\u79cd\u5e7f\u6cdb\u5e94\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5176\u4e0d\u540c\u7684\u7248\u672c\u5f80\u5f80\u7528\u4e8e\u4e0d\u540c\u7684\u9879\u76ee\u3002\u5728Ubuntu\u7cfb\u7edf\u4e0a\uff0c\u9ed8\u8ba4\u5b89\u88c5\u6709Python 2.x\u548cPython 3.x\u4e24\u4e2a\u5927\u7248\u672c\u3002\u8fd9\u4e24\u4e2a\u7248\u672c\u5177\u6709\u4e0d\u5b8c\u5168\u517c\u5bb9\u7684\u8bed\u8a00\u7279\u6027\u548c\u5e93\u652f\u6301\uff0c\u56e0\u6b64\u5f00\u53d1\u8005\u53ef\u80fd\u9700\u8981\u9488\u5bf9\u4e0d\u540c\u7684\u9879\u76ee\u5207\u6362Python\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u914d\u7f6eupdate-alternatives\u5b9e\u73b0\u7248\u672c\u5207\u6362<\/h3>\n<\/p>\n<p><p>Ubuntu\u7cfb\u7edf\u4f7f\u7528update-alternatives\u7ba1\u7406\u8f6f\u4ef6\u7248\u672c\uff0c\u8fd9\u4e5f\u9002\u7528\u4e8ePython\u3002<\/p>\n<\/p>\n<p><p><strong>1. \u8bbe\u7f6eupdate-alternatives<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528update-alternatives\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u8ba4\u7cfb\u7edf\u5df2\u5b89\u88c5\u4e86\u9700\u8981\u7684Python\u7248\u672c\u3002\u901a\u8fc7<code>sudo apt install python2.7 python3.8<\/code>\u7b49\u547d\u4ee4\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684Python\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528<code>sudo update-alternatives --install \/usr\/bin\/python python \/usr\/bin\/python2.7 1<\/code>\u547d\u4ee4\u8bbe\u7f6ePython 2.7\u4e3a\u4e00\u4e2a\u53ef\u9009\u62e9\u7684\u66ff\u4ee3\u9009\u9879\uff0c\u5176\u4e2d<code>1<\/code>\u662f\u4f18\u5148\u7ea7\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u5207\u6362\u7248\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5f53\u7cfb\u7edf\u4e2d\u8bbe\u7f6e\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\u540e\uff0c\u901a\u8fc7\u547d\u4ee4<code>sudo update-alternatives --config python<\/code>\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u53ef\u7528\u7684Python\u7248\u672c\uff0c\u5e76\u5141\u8bb8\u7528\u6237\u9009\u62e9\u9ed8\u8ba4\u7684\u7248\u672c\u3002\u6bcf\u4e2a\u7248\u672c\u65c1\u8fb9\u4f1a\u6709\u5b83\u7684\u4f18\u5148\u7ea7\u548c\u4f7f\u7528\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528pyenv\u8fdb\u884cPython\u7248\u672c\u7ba1\u7406<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u7ba1\u7406\u66f4\u591a\u7248\u672c\u7684Python\u6216\u8005\u5e0c\u671b\u5728\u7528\u6237\u7ea7\u522b\u5207\u6362Python\u7248\u672c\uff0cpyenv\u662f\u4e00\u4e2a\u975e\u5e38\u9002\u5408\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><p><strong>1. \u5b89\u88c5pyenv<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u5b89\u88c5pyenv\uff0c\u53ef\u4ee5\u901a\u8fc7git\u514b\u9686\u5176\u4ed3\u5e93<code>git clone https:\/\/github.com\/pyenv\/pyenv.git ~\/.pyenv<\/code>\uff0c\u7136\u540e\u6dfb\u52a0\u521d\u59cb\u5316\u4ee3\u7801\u5230shell\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f8b\u5982<code>.bashrc<\/code>\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u7ba1\u7406Python\u7248\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>pyenv install 3.8.1<\/code>\u6765\u5b89\u88c5Python 3.8.1\u7248\u672c\uff0c\u901a\u8fc7<code>pyenv versions<\/code>\u5217\u51fa\u6240\u6709\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u5e76\u53ef\u4ee5\u7528<code>pyenv global 3.8.1<\/code>\u6765\u5168\u5c40\u5730\u5207\u6362\u5230\u8be5\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5229\u7528\u865a\u62df\u73af\u5883\u9694\u79bb\u9879\u76ee\u4f9d\u8d56<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662fPython<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a>\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u6982\u5ff5\uff0c\u5b83\u5141\u8bb8\u521b\u5efa\u4e00\u4e2a\u5e72\u51c0\u7684\u73af\u5883\u7528\u4e8e\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><p><strong>1. \u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Python\u81ea\u5e26\u7684venv\u6a21\u5757\u6216virtualenv\u5de5\u5177\u53ef\u4ee5\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u4f8b\u5982\uff0c\u8fd0\u884c<code>python3 -m venv my_project_env<\/code>\u5c06\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amy_project_env\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u4f9d\u8d56\u4e8e\u4f7f\u7528\u7684shell\u3002\u901a\u5e38\uff0c\u5728bash\u4e2d\u4f7f\u7528<code>source my_project_env\/bin\/activate<\/code>\u5373\u53ef\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0c\u5728\u73af\u5883\u4e2d\u5b89\u88c5\u7684\u5305\u5c06\u548c\u7cfb\u7edf\u7ea7\u522b\u9694\u79bb\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u5bb9\u5668\u6280\u672f\u4fdd\u6301\u73af\u5883\u4e00\u81f4\u6027<\/h3>\n<\/p>\n<p><p>\u5bb9\u5668\u6280\u672f\u5982Docker\u4e5f\u662f\u7ba1\u7406Python\u73af\u5883\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u5b83\u80fd\u591f\u4fdd\u6301\u5f00\u53d1\u3001\u6d4b\u8bd5\u548c\u751f\u4ea7\u73af\u5883\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<p><p><strong>1. \u521b\u5efaDocker\u5bb9\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u7f16\u5199Dockerfile\u6765\u786e\u5b9aPython\u73af\u5883\uff0c\u5176\u4e2d\u53ef\u4ee5\u6307\u5b9a\u9700\u8981\u7684Python\u7248\u672c\u548c\u5fc5\u8981\u7684\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u8fd0\u884c\u548c\u7ba1\u7406\u5bb9\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Docker\u547d\u4ee4\u5982<code>docker build<\/code>\u548c<code>docker run<\/code>\u6765\u6784\u5efa\u955c\u50cf\u548c\u8fd0\u884c\u5bb9\u5668\u3002\u5bb9\u5668\u5185\u90e8\u7684Python\u73af\u5883\u662f\u72ec\u7acb\u7684\uff0c\u5e76\u4e14\u4e0d\u4f1a\u5f71\u54cd\u5230\u4e3b\u673a\u7cfb\u7edf\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u989d\u5916\u7684\u5de5\u5177\u548c\u8003\u8651\u56e0\u7d20<\/h3>\n<\/p>\n<p><p>Ubuntu\u7cfb\u7edf\u4e0b\u8fd8\u6709\u5176\u4ed6\u7ba1\u7406Python\u7248\u672c\u7684\u5de5\u5177\uff0c\u5982conda\u3001virtualenvwrapper\u7b49\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u529f\u80fd\u548c\u65b9\u4fbf\u7684\u7ba1\u7406\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><p>\u540c\u65f6\uff0c\u9700\u8981\u6ce8\u610fPython\u73af\u5883\u5207\u6362\u53ef\u80fd\u4f1a\u5bf9\u7cfb\u7edf\u5de5\u5177\u9020\u6210\u5f71\u54cd\uff0c\u4e00\u4e9b\u4f9d\u8d56\u7279\u5b9aPython\u7248\u672c\u7684\u7cfb\u7edf\u5de5\u5177\u9700\u8981\u8c28\u614e\u5904\u7406\u3002<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u4ece\u591a\u65b9\u9762\u638c\u63e1\u5728Ubuntu\u7cfb\u7edf\u4e0b\u5207\u6362Python\u7248\u672c\u7684\u77e5\u8bc6\u548c\u6280\u5de7\uff0c\u4eceupdate-alternatives\u5230pyenv\uff0c\u518d\u5230\u865a\u62df\u73af\u5883\u548c\u5bb9\u5668\u6280\u672f\uff0c\u6211\u4eec\u6709\u5fc5\u8981\u5168\u9762\u4e86\u89e3\u5b83\u4eec\u5404\u81ea\u7684\u5e94\u7528\u573a\u666f\u548c\u4f18\u7f3a\u70b9\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u6c42\u548c\u4e2a\u4eba\u504f\u597d\u5b9e\u73b0Python\u7248\u672c\u7684\u9ad8\u6548\u5207\u6362\u548c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u95ee\u98981\uff1a\u5728Ubuntu\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5982\u4f55\u66f4\u6539Python\u7684\u7248\u672c\uff1f<\/strong><\/p>\n<p>\u56de\u7b54\uff1a\u66f4\u6539Ubuntu\u7cfb\u7edf\u4e2d\u7684Python\u7248\u672c\u76f8\u5bf9\u7b80\u5355\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u6765\u5207\u6362Python\u7684\u7248\u672c\uff1a<\/p>\n<ol>\n<li>\n<p>\u68c0\u67e5\u7cfb\u7edf\u4e2d\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\uff1a\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u547d\u4ee4<code>python --version<\/code>\uff0c\u53ef\u4ee5\u67e5\u770b\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5\u5176\u4ed6\u7248\u672c\u7684Python\uff1a\u53ef\u4ee5\u4f7f\u7528 <code>apt-get<\/code> \u547d\u4ee4\u6765\u5b89\u88c5\u5176\u4ed6\u7248\u672c\u7684Python\uff0c\u4f8b\u5982\u5b89\u88c5Python3.7\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 <code>sudo apt-get install python3.7<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p>\u5207\u6362\u4f7f\u7528\u7684Python\u7248\u672c\uff1a\u4f7f\u7528 <code>update-alternatives<\/code> \u547d\u4ee4\u6765\u9009\u62e9\u9ed8\u8ba4\u4f7f\u7528\u7684Python\u7248\u672c\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u547d\u4ee4 <code>sudo update-alternatives --config python<\/code>\uff0c\u7136\u540e\u9009\u62e9\u8981\u4f7f\u7528\u7684Python\u7248\u672c\uff0c\u6309\u7167\u63d0\u793a\u8fdb\u884c\u64cd\u4f5c\u5373\u53ef\u3002<\/p>\n<\/li>\n<li>\n<p>\u9a8c\u8bc1\u66f4\u6539\uff1a\u518d\u6b21\u8fd0\u884c\u547d\u4ee4 <code>python --version<\/code>\uff0c\u53ef\u4ee5\u786e\u8ba4\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\u662f\u5426\u5df2\u7ecf\u66f4\u6539\u3002<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u95ee\u98982\uff1a\u5728Ubuntu\u4e0a\u5982\u4f55\u540c\u65f6\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c\uff1f<\/strong><\/p>\n<p>\u56de\u7b54\uff1a\u5728Ubuntu\u4e0a\u540c\u65f6\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c\u53ef\u4ee5\u901a\u8fc7pyenv\u5de5\u5177\u6765\u5b9e\u73b0\u3002pyenv\u662f\u4e00\u4e2aPython\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u5207\u6362\u4e0d\u540c\u7248\u672c\u7684Python\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5\u548c\u4f7f\u7528pyenv\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u5b89\u88c5pyenv\uff1a\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5pyenv\uff1a<\/li>\n<\/ol>\n<pre><code class=\"language-bash\">curl https:\/\/pyenv.run | bash\n<\/code><\/pre>\n<ol start=\"2\">\n<li>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a\u6253\u5f00\u7ec8\u7aef\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u4f8b\u5982\uff1a~\/.bashrc, ~\/.zshrc\uff09\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/li>\n<\/ol>\n<pre><code class=\"language-bash\">export PYENV_ROOT=&quot;$HOME\/.pyenv&quot;\nexport PATH=&quot;$PYENV_ROOT\/bin:$PATH&quot;\neval &quot;$(pyenv init --path)&quot;\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u6587\u4ef6\uff0c\u7136\u540e\u8fd0\u884c <code>source ~\/.bashrc<\/code> \u6216 <code>source ~\/.zshrc<\/code> \u4f7f\u73af\u5883\u53d8\u91cf\u751f\u6548\u3002<\/p>\n<ol start=\"3\">\n<li>\u5b89\u88c5\u6240\u9700\u7248\u672c\u7684Python\uff1a\u8fd0\u884c <code>pyenv install &lt;version&gt;<\/code> \u547d\u4ee4\u6765\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u4f8b\u5982 <code>pyenv install 3.7.9<\/code>\u3002<\/li>\n<li>\u5207\u6362Python\u7248\u672c\uff1a\u4f7f\u7528 <code>pyenv global &lt;version&gt;<\/code> \u547d\u4ee4\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u4f7f\u7528\u7684Python\u7248\u672c\uff0c\u4f8b\u5982 <code>pyenv global 3.7.9<\/code>\u3002<\/li>\n<li>\u9a8c\u8bc1\u66f4\u6539\uff1a\u8fd0\u884c <code>python --version<\/code> \u547d\u4ee4\u6765\u9a8c\u8bc1\u9ed8\u8ba4\u7684Python\u7248\u672c\u662f\u5426\u5df2\u7ecf\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p><strong>\u95ee\u98983\uff1a\u5982\u4f55\u5728Ubuntu\u4e0a\u7ba1\u7406Python\u865a\u62df\u73af\u5883\uff1f<\/strong><\/p>\n<p>\u56de\u7b54\uff1a\u5728Ubuntu\u4e0a\u53ef\u4ee5\u4f7f\u7528<code>virtualenv<\/code>\u6765\u7ba1\u7406Python\u865a\u62df\u73af\u5883\uff0c\u5b83\u5141\u8bb8\u60a8\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u521b\u5efa\u591a\u4e2a\u72ec\u7acb\u7684Python\u73af\u5883\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528<code>virtualenv<\/code>\u521b\u5efa\u548c\u7ba1\u7406Python\u865a\u62df\u73af\u5883\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5<code>virtualenv<\/code>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>pip install virtualenv<\/code>\u547d\u4ee4\u6765\u5b89\u88c5<code>virtualenv<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a\u4f7f\u7528<code>virtualenv<\/code>\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u4f8b\u5982<code>virtualenv myenv<\/code>\uff0c\u8fd9\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/li>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>source myenv\/bin\/activate<\/code>\u547d\u4ee4\u6765\u6fc0\u6d3b\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u540e\uff0c\u60a8\u5c06\u5728\u7ec8\u7aef\u63d0\u793a\u7b26\u4e2d\u770b\u5230\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5\u4f9d\u8d56\u5305\uff1a\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684Python\u5305\uff0c\u4f8b\u5982<code>pip install numpy<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u865a\u62df\u73af\u5883\uff1a\u4f7f\u7528\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u6765\u8fd0\u884cPython\u7a0b\u5e8f\u6216\u4f7f\u7528Python\u89e3\u91ca\u5668\uff0c\u6240\u6709\u5b89\u88c5\u7684\u5305\u90fd\u5c06\u5728\u8be5\u865a\u62df\u73af\u5883\u4e2d\u751f\u6548\u3002<\/p>\n<\/li>\n<li>\n<p>\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>deactivate<\/code>\u547d\u4ee4\u6765\u9000\u51fa\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4f7f\u7528<code>virtualenv<\/code>\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u591a\u4e2a\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u6bcf\u4e2a\u73af\u5883\u4e2d\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\u548c\u4f9d\u8d56\u5305\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528\u591a\u7248\u672c\u7684Python\u7684\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a\u5728Ubuntu\u7cfb\u7edf\u4e0b\u5207\u6362Python\u7248\u672c\u3001\u4f7f\u7528update-alter [&hellip;]","protected":false},"author":3,"featured_media":176682,"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\/176673"}],"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=176673"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/176673\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/176682"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=176673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=176673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=176673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}