{"id":1015474,"date":"2024-12-27T12:07:48","date_gmt":"2024-12-27T04:07:48","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1015474.html"},"modified":"2024-12-27T12:07:51","modified_gmt":"2024-12-27T04:07:51","slug":"%e5%a6%82%e4%bd%95%e6%90%ad%e5%bb%bapython%e8%bf%90%e8%a1%8c%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1015474.html","title":{"rendered":"\u5982\u4f55\u642d\u5efapython\u8fd0\u884c\u73af\u5883"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25095323\/9d293b17-5554-4275-aa56-8515381abb71.webp\" alt=\"\u5982\u4f55\u642d\u5efapython\u8fd0\u884c\u73af\u5883\" \/><\/p>\n<p><p> <strong>\u642d\u5efaPython\u8fd0\u884c\u73af\u5883\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u9694\u79bb<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u9694\u79bb\u662f\u5173\u952e\u6b65\u9aa4\uff0c\u56e0\u4e3a\u5b83\u80fd\u786e\u4fdd\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u4e0d\u51b2\u7a81\uff0c\u4fdd\u6301\u5f00\u53d1\u73af\u5883\u7684\u6574\u6d01\u3002\u901a\u8fc7\u5de5\u5177\u5982<code>venv<\/code>\u6216<code>virtualenv<\/code>\uff0c\u53ef\u4ee5\u521b\u5efa\u72ec\u7acb\u7684\u865a\u62df\u73af\u5883\uff0c\u4e3a\u6bcf\u4e2a\u9879\u76ee\u5b89\u88c5\u6240\u9700\u7684\u5305\u548c\u6a21\u5757\uff0c\u8fd9\u6837\u5373\u4fbf\u9879\u76ee\u4e4b\u95f4\u6709\u4f9d\u8d56\u51b2\u7a81\uff0c\u4e5f\u4e0d\u4f1a\u76f8\u4e92\u5f71\u54cd\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u642d\u5efaPython\u8fd0\u884c\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c<\/h2>\n<\/p>\n<p><p>\u5728\u642d\u5efaPython\u8fd0\u884c\u73af\u5883\u4e4b\u524d\uff0c\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u867d\u7136Python2\u4ecd\u7136\u5b58\u5728\u4e8e\u4e00\u4e9b\u65e7\u7684\u9879\u76ee\u4e2d\uff0c\u4f46Python3\u662f\u76ee\u524d\u7684\u4e3b\u6d41\u7248\u672c\uff0c\u5e76\u4e14\u5927\u591a\u6570\u65b0\u529f\u80fd\u548c\u66f4\u65b0\u90fd\u662f\u57fa\u4e8ePython3\u8fdb\u884c\u7684\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u9009\u62e9Python3\u6765\u642d\u5efa\u65b0\u7684\u8fd0\u884c\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7248\u672c\u517c\u5bb9\u6027<\/strong>\uff1a\u9009\u62e9Python\u7248\u672c\u65f6\uff0c\u9700\u8003\u8651\u6240\u9700\u5e93\u6216\u6846\u67b6\u7684\u517c\u5bb9\u6027\u3002\u67d0\u4e9b\u5e93\u53ef\u80fd\u53ea\u652f\u6301\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u56e0\u6b64\u5728\u786e\u5b9a\u9879\u76ee\u4f7f\u7528\u7684\u5e93\u540e\uff0c\u68c0\u67e5\u8fd9\u4e9b\u5e93\u7684\u6587\u6863\u4ee5\u786e\u8ba4\u652f\u6301\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u957f\u671f\u652f\u6301\uff08LTS\uff09\u7248\u672c<\/strong>\uff1a\u9009\u62e9\u957f\u671f\u652f\u6301\u7248\u672c\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u7248\u672c\u4f1a\u5f97\u5230\u66f4\u957f\u65f6\u95f4\u7684\u652f\u6301\u548c\u66f4\u65b0\uff0c\u786e\u4fdd\u5b89\u5168\u6027\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e8c\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668<\/h2>\n<\/p>\n<p><p>\u5b89\u88c5Python\u89e3\u91ca\u5668\u662f\u642d\u5efaPython\u8fd0\u884c\u73af\u5883\u7684\u57fa\u7840\u6b65\u9aa4\u3002\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\uff0c\u5b89\u88c5\u8fc7\u7a0b\u4f1a\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows\u7cfb\u7edf<\/strong>\uff1a\u53ef\u4ee5\u4ecePython\u5b98\u7f51\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E9%80%82%E5%90%88Windows%E7%9A%84%E5%AE%89%E8%A3%85%E5%8C%85%E3%80%82%E5%AE%89%E8%A3%85%E8%BF%87%E7%A8%8B%E4%B8%AD%EF%BC%8C%E5%8A%A1%E5%BF%85%E5%8B%BE%E9%80%89%E2%80%9CAdd\">https:\/\/www.python.org\/\uff09\u4e0b\u8f7d\u9002\u5408Windows\u7684\u5b89\u88c5\u5305\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u52a1\u5fc5\u52fe\u9009\u201cAdd<\/a> Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u81ea\u52a8\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u65b9\u4fbf\u540e\u7eed\u4f7f\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>macOS\u7cfb\u7edf<\/strong>\uff1amacOS\u901a\u5e38\u9884\u88c5\u6709Python\uff0c\u4f46\u53ef\u80fd\u662f\u65e7\u7248\u672c\u3002\u5efa\u8bae\u4f7f\u7528Homebrew\u6765\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/p>\n<p>brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>Linux\u7cfb\u7edf<\/strong>\uff1a\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u4e5f\u9884\u88c5\u4e86Python\u3002\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982apt\u3001yum\u7b49\uff09\u5b89\u88c5\u6216\u5347\u7ea7Python\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update<\/p>\n<p>sudo apt install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e09\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h2>\n<\/p>\n<p><p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u662f\u4e3a\u4e86\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u8bbf\u95eePython\u89e3\u91ca\u5668\u548c\u76f8\u5173\u5de5\u5177\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Windows\u7cfb\u7edf<\/strong>\uff1a\u5982\u679c\u5728\u5b89\u88c5Python\u65f6\u672a\u52fe\u9009\u201cAdd Python to PATH\u201d\uff0c\u9700\u624b\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u8fdb\u5165\u201c\u63a7\u5236\u9762\u677f -&gt; \u7cfb\u7edf\u548c\u5b89\u5168 -&gt; \u7cfb\u7edf -&gt; \u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e -&gt; \u73af\u5883\u53d8\u91cf\u201d\uff0c\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e2d\u627e\u5230\u6216\u65b0\u5efa<code>PATH<\/code>\uff0c\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\u53ca<code>Scripts<\/code>\u76ee\u5f55\u6dfb\u52a0\u8fdb\u53bb\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>macOS\u548cLinux\u7cfb\u7edf<\/strong>\uff1a\u901a\u5e38\u4e0d\u9700\u8981\u989d\u5916\u914d\u7f6e\uff0c\u56e0\u4e3a\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u4f1a\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u5982\u679c\u9700\u8981\u624b\u52a8\u914d\u7f6e\uff0c\u53ef\u4ee5\u7f16\u8f91<code>~\/.bashrc<\/code>\u6216<code>~\/.zshrc<\/code>\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u9694\u79bb<\/h2>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662fPython\u5f00\u53d1\u4e2d\u7684\u91cd\u8981\u5de5\u5177\uff0c\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684\u5305\u4f9d\u8d56\u73af\u5883\uff0c\u9632\u6b62\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u4f7f\u7528Python\u5185\u7f6e\u7684<code>venv<\/code>\u6a21\u5757\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u6240\u6709\u5b89\u88c5\u7684\u5305\u548c\u6a21\u5757\u90fd\u5c06\u4fdd\u5b58\u5728\u8be5\u73af\u5883\u4e2d\u3002\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\uff0c\u6fc0\u6d3b\u547d\u4ee4\u6709\u6240\u4e0d\u540c\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Windows<\/strong>\uff1a<code>myenv\\Scripts\\activate<\/code><\/li>\n<li><strong>macOS\u548cLinux<\/strong>\uff1a<code>source myenv\/bin\/activate<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56<\/strong>\uff1a\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\u5305\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5b8c\u6210\u5f00\u53d1\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e94\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177<\/h2>\n<\/p>\n<p><p>\u5305\u7ba1\u7406\u5de5\u5177\u662f\u7ba1\u7406Python\u9879\u76ee\u4f9d\u8d56\u7684\u5173\u952e\u3002<code>pip<\/code>\u662fPython\u7684\u9ed8\u8ba4\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u4f46\u8fd8\u6709\u5176\u4ed6\u5de5\u5177\u53ef\u4f9b\u9009\u62e9\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>pip<\/strong>\uff1a<code>pip<\/code>\u662fPython\u7684\u9ed8\u8ba4\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip install &lt;package&gt;<\/code>\u5b89\u88c5\u5305\uff0c<code>pip uninstall &lt;package&gt;<\/code>\u5378\u8f7d\u5305\uff0c<code>pip list<\/code>\u5217\u51fa\u5df2\u5b89\u88c5\u7684\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>pipenv<\/strong>\uff1a<code>pipenv<\/code>\u662f\u4e00\u4e2a\u66f4\u9ad8\u7ea7\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u96c6\u6210\u4e86<code>pip<\/code>\u548c<code>virtualenv<\/code>\u7684\u529f\u80fd\uff0c\u63d0\u4f9b\u66f4\u597d\u7684\u4f9d\u8d56\u7ba1\u7406\u548c\u73af\u5883\u9694\u79bb\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5<code>pipenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pipenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>pipenv install &lt;package&gt;<\/code>\u5b89\u88c5\u5305\uff0c\u81ea\u52a8\u7ba1\u7406\u865a\u62df\u73af\u5883\u548c<code>Pipfile<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>conda<\/strong>\uff1a<code>conda<\/code>\u662fAnaconda\u53d1\u884c\u7248\u4e2d\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u9664\u4e86Python\u5305\uff0c\u8fd8\u53ef\u4ee5\u7ba1\u7406\u5176\u4ed6\u8bed\u8a00\u7684\u5305\u3002\u9002\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u9879\u76ee\u3002\u53ef\u4ee5\u4eceAnaconda\u5b98\u7f51\uff08<a href=\"https:\/\/www.anaconda.com\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E3%80%82\">https:\/\/www.anaconda.com\/\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u516d\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u7684\u9009\u62e9<\/h2>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>PyCharm<\/strong>\uff1aPyCharm\u662fJetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u5f00\u53d1\u7684\u5f3a\u5927IDE\uff0c\u652f\u6301\u591a\u79cdPython\u6846\u67b6\u548c\u5e93\uff0c\u63d0\u4f9b\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002\u5206\u4e3a\u793e\u533a\u7248\uff08\u514d\u8d39\uff09\u548c\u4e13\u4e1a\u7248\uff08\u6536\u8d39\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Visual Studio Code<\/strong>\uff1aVS Code\u662f\u5fae\u8f6f\u5f00\u53d1\u7684\u8f7b\u91cf\u7ea7\u7f16\u8f91\u5668\uff0c\u901a\u8fc7\u5b89\u88c5Python\u63d2\u4ef6\uff0c\u53ef\u4ee5\u63d0\u4f9b\u7c7b\u4f3cIDE\u7684\u529f\u80fd\uff0c\u5982\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u3001Linting\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Jupyter Notebook<\/strong>\uff1a\u9002\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u79d1\u5b66\u8ba1\u7b97\u9879\u76ee\uff0c\u63d0\u4f9b\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u73af\u5883\u3002\u53ef\u4ee5\u901a\u8fc7<code>pip install jupyter<\/code>\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e03\u3001\u8bbe\u7f6e\u548c\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56<\/h2>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u5f00\u53d1\u4e2d\uff0c\u7ba1\u7406\u597d\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528<code>requirements.txt<\/code>\u6587\u4ef6<\/strong>\uff1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u521b\u5efa<code>requirements.txt<\/code>\u6587\u4ef6\uff0c\u5217\u51fa\u6240\u6709\u9879\u76ee\u4f9d\u8d56\u5305\u53ca\u5176\u7248\u672c\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210<code>requirements.txt<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip freeze &gt; requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>pip install -r requirements.txt<\/code>\u5b89\u88c5\u6587\u4ef6\u4e2d\u5217\u51fa\u7684\u6240\u6709\u4f9d\u8d56\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528<code>Pipfile<\/code>\u548c<code>Pipfile.lock<\/code><\/strong>\uff1a\u5982\u679c\u4f7f\u7528<code>pipenv<\/code>\u7ba1\u7406\u9879\u76ee\uff0c\u53ef\u4ee5\u81ea\u52a8\u751f\u6210<code>Pipfile<\/code>\u548c<code>Pipfile.lock<\/code>\u6587\u4ef6\uff0c\u8bb0\u5f55\u9879\u76ee\u4f9d\u8d56\u548c\u7cbe\u786e\u7248\u672c\u3002\u4f7f\u7528<code>pipenv install<\/code>\u65f6\u4f1a\u66f4\u65b0\u8fd9\u4e9b\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u516b\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/h2>\n<\/p>\n<p><p>\u5728\u642d\u5efa\u548c\u4f7f\u7528Python\u8fd0\u884c\u73af\u5883\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u9519\u8bef<\/strong>\uff1a\u5982\u679cPython\u547d\u4ee4\u65e0\u6cd5\u8bc6\u522b\uff0c\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u662f\u5426\u6b63\u786e\uff0c\u786e\u4fddPython\u8def\u5f84\u5df2\u6dfb\u52a0\u5230<code>PATH<\/code>\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u865a\u62df\u73af\u5883\u65e0\u6cd5\u6fc0\u6d3b<\/strong>\uff1a\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u53ef\u80fd\u5931\u8d25\u3002\u68c0\u67e5\u547d\u4ee4\u662f\u5426\u6b63\u786e\uff0c\u5e76\u786e\u4fdd\u7ec8\u7aef\u5177\u6709\u6267\u884c\u6743\u9650\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u51b2\u7a81<\/strong>\uff1a\u5b89\u88c5\u67d0\u4e9b\u5305\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u7248\u672c\u51b2\u7a81\u3002\u53ef\u4ee5\u4f7f\u7528\u865a\u62df\u73af\u5883\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\uff0c\u6216\u8005\u624b\u52a8\u8c03\u6574<code>requirements.txt<\/code>\u4e2d\u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\u5728\u5b89\u88c5\u5305\u65f6\u53ef\u80fd\u9047\u5230\u6743\u9650\u9519\u8bef\u3002\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\uff0c\u6216\u8005\u4f7f\u7528<code>--user<\/code>\u9009\u9879\u5b89\u88c5\u5230\u7528\u6237\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u6210\u529f\u642d\u5efa\u4e00\u4e2a\u9ad8\u6548\u3001\u53ef\u9760\u7684Python\u8fd0\u884c\u73af\u5883\uff0c\u4e3a\u5f00\u53d1Python\u9879\u76ee\u5960\u5b9a\u575a\u5b9e\u7684\u57fa\u7840\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u7684Python\u7248\u672c\u8fdb\u884c\u642d\u5efa\uff1f<\/strong><br \/>\u5728\u9009\u62e9Python\u7248\u672c\u65f6\uff0c\u5efa\u8bae\u8003\u8651\u9879\u76ee\u9700\u6c42\u548c\u517c\u5bb9\u6027\u3002\u901a\u5e38\uff0c\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u4f1a\u5305\u542b\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u4fee\u590d\uff0c\u9002\u5408\u65b0\u9879\u76ee\u3002\u5982\u679c\u4f60\u6b63\u5728\u7ef4\u62a4\u65e7\u9879\u76ee\uff0c\u786e\u4fdd\u4f7f\u7528\u4e0e\u9879\u76ee\u76f8\u5339\u914d\u7684\u7248\u672c\u3002\u6b64\u5916\uff0c\u67d0\u4e9b\u5e93\u548c\u6846\u67b6\u53ef\u80fd\u53ea\u652f\u6301\u7279\u5b9a\u7248\u672c\uff0c\u68c0\u67e5\u76f8\u5173\u6587\u6863\u4ee5\u83b7\u5f97\u6700\u4f73\u9009\u62e9\u3002<\/p>\n<p><strong>\u642d\u5efaPython\u73af\u5883\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4f9d\u8d56\u5e93\uff1f<\/strong><br \/>\u5728\u642d\u5efaPython\u73af\u5883\u65f6\uff0c\u5e38\u89c1\u7684\u4f9d\u8d56\u5e93\u5305\u62ecpip\uff08Python\u5305\u7ba1\u7406\u5de5\u5177\uff09\u3001virtualenv\uff08\u7528\u4e8e\u521b\u5efa\u9694\u79bb\u7684Python\u73af\u5883\uff09\u4ee5\u53ca\u5e38\u7528\u7684\u6846\u67b6\u548c\u5e93\u5982Django\u3001Flask\u6216NumPy\u7b49\u3002\u6839\u636e\u4f60\u7684\u9879\u76ee\u9700\u6c42\uff0c\u63d0\u524d\u5217\u51fa\u5fc5\u8981\u7684\u5e93\uff0c\u5e76\u4f7f\u7528requirements.txt\u6587\u4ef6\u6765\u7ba1\u7406\u4f9d\u8d56\uff0c\u4ee5\u4fbf\u8f7b\u677e\u5b89\u88c5\u548c\u66f4\u65b0\u3002<\/p>\n<p><strong>\u5728Windows\u548cLinux\u7cfb\u7edf\u4e0a\u642d\u5efaPython\u73af\u5883\u6709\u4f55\u4e0d\u540c\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u642d\u5efaPython\u73af\u5883\u901a\u5e38\u901a\u8fc7\u4e0b\u8f7dPython\u5b89\u88c5\u5305\u5e76\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u5b8c\u6210\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u9009\u62e9\u6dfb\u52a0Python\u5230\u7cfb\u7edfPATH\u3002\u76f8\u5bf9\u800c\u8a00\uff0c\u5728Linux\u7cfb\u7edf\u4e0a\uff0c\u901a\u5e38\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982apt\u6216yum\uff09\u8fdb\u884c\u5b89\u88c5\uff0c\u547d\u4ee4\u884c\u64cd\u4f5c\u66f4\u4e3a\u5e38\u89c1\u3002\u65e0\u8bba\u662f\u54ea\u79cd\u7cfb\u7edf\uff0c\u786e\u4fdd\u5728\u5b89\u88c5\u540e\u9a8c\u8bc1Python\u662f\u5426\u6b63\u786e\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python --version<\/code>\u547d\u4ee4\u8fdb\u884c\u68c0\u67e5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u642d\u5efaPython\u8fd0\u884c\u73af\u5883\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df [&hellip;]","protected":false},"author":3,"featured_media":1015479,"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\/1015474"}],"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=1015474"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1015474\/revisions"}],"predecessor-version":[{"id":1015482,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1015474\/revisions\/1015482"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1015479"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1015474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1015474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1015474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}