{"id":1007161,"date":"2024-12-27T10:50:50","date_gmt":"2024-12-27T02:50:50","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1007161.html"},"modified":"2024-12-27T10:50:55","modified_gmt":"2024-12-27T02:50:55","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8linux%e5%bc%80%e5%8f%91python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1007161.html","title":{"rendered":"\u5982\u4f55\u5728linux\u5f00\u53d1python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25082958\/abaeb53a-ea15-40ca-ae20-03b91fe1b105.webp\" alt=\"\u5982\u4f55\u5728linux\u5f00\u53d1python\" \/><\/p>\n<p><p> \u5728Linux\u4e0a\u5f00\u53d1Python\u7684\u5173\u952e\u8981\u7d20\u5305\u62ec\uff1a<strong>\u5b89\u88c5Python\u73af\u5883\u3001\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u5de5\u5177\u3001\u638c\u63e1\u57fa\u672c\u7684Linux\u547d\u4ee4\u3001\u719f\u6089Python\u5e93\u7ba1\u7406\u3001\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801<\/strong>\u3002\u5176\u4e2d\uff0c\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u5de5\u5177\u662f\u81f3\u5173\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u56e0\u4e3a\u8fd9\u5c06\u76f4\u63a5\u5f71\u54cd\u5230\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u5728Linux\u73af\u5883\u4e0b\uff0c\u63a8\u8350\u4f7f\u7528\u7684\u5f00\u53d1\u5de5\u5177\u5305\u62ec\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982Vim\u3001Emacs\uff09\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08\u5982PyCharm\u3001VSCode\uff09\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u4e0d\u4ec5\u652f\u6301Python\u8bed\u6cd5\u9ad8\u4eae\uff0c\u8fd8\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u63d2\u4ef6\u751f\u6001\uff0c\u53ef\u4ee5\u6781\u5927\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002\u4f8b\u5982\uff0cPyCharm\u4f5c\u4e3a\u4e00\u6b3e\u4e13\u4e1a\u7684Python IDE\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u5de5\u5177\u3001\u4ee3\u7801\u81ea\u52a8\u8865\u5168\u548c\u7248\u672c\u63a7\u5236\u96c6\u6210\u7b49\u529f\u80fd\uff0c\u4f7f\u5f97\u5f00\u53d1\u8fc7\u7a0b\u66f4\u52a0\u987a\u7545\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5Python\u73af\u5883<\/p>\n<\/p>\n<p><p>\u5728Linux\u4e0a\u5f00\u53d1Python\u7684\u7b2c\u4e00\u6b65\u662f\u5b89\u88c5Python\u73af\u5883\u3002\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u5df2\u7ecf\u9884\u88c5\u4e86Python\uff0c\u4f46\u7248\u672c\u53ef\u80fd\u4e0d\u662f\u6700\u65b0\u7684\u3002\u4e3a\u4e86\u786e\u4fdd\u4f7f\u7528\u6700\u65b0\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b89\u88c5\u6216\u66f4\u65b0Python\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u6709\u4e0d\u540c\u7684\u5305\u7ba1\u7406\u5668\uff0c\u4f8b\u5982Ubuntu\u4f7f\u7528<code>apt<\/code>\uff0cFedora\u4f7f\u7528<code>dnf<\/code>\u3002\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5Python\u901a\u5e38\u662f\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u3002\u4ee5Ubuntu\u4e3a\u4f8b\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python 3\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<p><p>\u8fd9\u5c06\u5b89\u88c5Python 3\u7684\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u6e90\u7801\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u7f51\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E6%BA%90%E7%A0%81%E5%B9%B6%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85%E3%80%82%E4%BB%A5%E4%B8%8B%E6%98%AF%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%9A%84%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4%EF%BC%9A\">https:\/\/www.python.org\/\uff09\u4e0b\u8f7d\u6e90\u7801\u5e76\u7f16\u8bd1\u5b89\u88c5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b89\u88c5\u6b65\u9aa4\uff1a<\/a><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">wget https:\/\/www.python.org\/ftp\/python\/3.x.x\/Python-3.x.x.tgz<\/p>\n<p>tar xvf Python-3.x.x.tgz<\/p>\n<p>cd Python-3.x.x<\/p>\n<p>.\/configure --enable-optimizations<\/p>\n<p>make<\/p>\n<p>sudo make altinstall<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc\u7684<code>3.x.x<\/code>\u9700\u8981\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u5de5\u5177\u662f\u9ad8\u6548\u5f00\u53d1Python\u5e94\u7528\u7a0b\u5e8f\u7684\u5173\u952e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u63a8\u8350\u7684\u5de5\u5177\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6587\u672c\u7f16\u8f91\u5668<\/strong><\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>Vim<\/strong>\uff1aVim\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u9002\u5408\u559c\u6b22\u4f7f\u7528\u547d\u4ee4\u884c\u7684\u5f00\u53d1\u8005\u3002\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u63d2\u4ef6\uff08\u5982Vim-Plug\uff09\u6765\u589e\u5f3a\u5176\u529f\u80fd\uff0c\u4f8b\u5982\u81ea\u52a8\u8865\u5168\u3001\u8bed\u6cd5\u9ad8\u4eae\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Emacs<\/strong>\uff1aEmacs\u540c\u6837\u662f\u4e00\u4e2a\u529f\u80fd\u4e30\u5bcc\u7684\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u901a\u8fc7\u5b89\u88c5<code>elpy<\/code>\u63d2\u4ef6\uff0c\u53ef\u4ee5\u589e\u5f3a\u5bf9Python\u7684\u652f\u6301\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/strong><\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>PyCharm<\/strong>\uff1aPyCharm\u662fJetBrains\u63a8\u51fa\u7684\u4e00\u6b3e\u4e13\u4e1aPython\u5f00\u53d1IDE\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u4ee3\u7801\u5206\u6790\u3001\u8c03\u8bd5\u5de5\u5177\u548c<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a>\u529f\u80fd\u3002\u5b83\u652f\u6301Git\u3001Docker\u7b49\u5f00\u53d1\u5de5\u5177\u7684\u96c6\u6210\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Visual Studio Code\uff08VSCode\uff09<\/strong>\uff1aVSCode\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684\u5f00\u6e90\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u901a\u8fc7\u5b89\u88c5Python\u63d2\u4ef6\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4ee3\u7801\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u638c\u63e1\u57fa\u672c\u7684Linux\u547d\u4ee4<\/p>\n<\/p>\n<p><p>\u5728Linux\u73af\u5883\u4e0b\u5f00\u53d1Python\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u7684Linux\u547d\u4ee4\uff0c\u4ee5\u4fbf\u6709\u6548\u5730\u7ba1\u7406\u6587\u4ef6\u548c\u76ee\u5f55\u3001\u67e5\u770b\u7cfb\u7edf\u8d44\u6e90\u3001\u4ee5\u53ca\u8fd0\u884c\u548c\u8c03\u8bd5\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6587\u4ef6\u548c\u76ee\u5f55\u64cd\u4f5c<\/strong><\/p>\n<\/p>\n<ul>\n<li><code>ls<\/code>\uff1a\u5217\u51fa\u76ee\u5f55\u5185\u5bb9\u3002<\/li>\n<li><code>cd<\/code>\uff1a\u6539\u53d8\u5f53\u524d\u76ee\u5f55\u3002<\/li>\n<li><code>cp<\/code>\uff1a\u590d\u5236\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/li>\n<li><code>mv<\/code>\uff1a\u79fb\u52a8\u6216\u91cd\u547d\u540d\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/li>\n<li><code>rm<\/code>\uff1a\u5220\u9664\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7cfb\u7edf\u8d44\u6e90\u67e5\u770b<\/strong><\/p>\n<\/p>\n<ul>\n<li><code>top<\/code>\uff1a\u52a8\u6001\u67e5\u770b\u7cfb\u7edf\u8fdb\u7a0b\u548c\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n<li><code>free<\/code>\uff1a\u67e5\u770b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n<li><code>df<\/code>\uff1a\u67e5\u770b\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7a0b\u5e8f\u8fd0\u884c\u548c\u8c03\u8bd5<\/strong><\/p>\n<\/p>\n<ul>\n<li><code>python3 script.py<\/code>\uff1a\u8fd0\u884cPython\u811a\u672c\u3002<\/li>\n<li><code>pdb<\/code>\uff1aPython\u81ea\u5e26\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u901a\u8fc7<code>python3 -m pdb script.py<\/code>\u6765\u8c03\u8bd5Python\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u719f\u6089Python\u5e93\u7ba1\u7406<\/p>\n<\/p>\n<p><p>Python\u7684\u5f3a\u5927\u4e4b\u5904\u5728\u4e8e\u5176\u4e30\u5bcc\u7684\u7b2c\u4e09\u65b9\u5e93\u751f\u6001\u3002\u5728Linux\u4e0a\u5f00\u53d1Python\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u719f\u6089\u5982\u4f55\u7ba1\u7406\u8fd9\u4e9b\u5e93\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528pip\u5b89\u88c5\u548c\u7ba1\u7406\u5e93<\/strong><\/p>\n<\/p>\n<p><p><code>pip<\/code>\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e5f\u53ef\u4ee5\u901a\u8fc7<code>pip list<\/code>\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\uff0c\u901a\u8fc7<code>pip uninstall package_name<\/code>\u5378\u8f7d\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u5e93\u7248\u672c\u51b2\u7a81\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u3002\u53ef\u4ee5\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv myenv<\/p>\n<p>source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801<\/p>\n<\/p>\n<p><p>\u5728Linux\u4e0a\u7f16\u5199\u548c\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u7684\u7f16\u7a0b\u6280\u5de7\u548c\u8c03\u8bd5\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f16\u5199\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u7f16\u5199Python\u4ee3\u7801\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee3\u7801\u98ce\u683c\u548c\u53ef\u8bfb\u6027\u3002\u53ef\u4ee5\u4f7f\u7528<code>pylint<\/code>\u6216<code>flake8<\/code>\u7b49\u5de5\u5177\u6765\u68c0\u67e5\u4ee3\u7801\u7684\u98ce\u683c\u548c\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u8c03\u8bd5\u4ee3\u7801\u662f\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u4e0d\u53ef\u907f\u514d\u7684\u4e00\u90e8\u5206\u3002\u5728Linux\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u8c03\u8bd5Python\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u4f7f\u7528print\u8bed\u53e5<\/strong>\uff1a\u5728\u4ee3\u7801\u4e2d\u63d2\u5165<code>print<\/code>\u8bed\u53e5\uff0c\u8f93\u51fa\u53d8\u91cf\u503c\u548c\u6267\u884c\u6d41\u7a0b\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pdb\u8c03\u8bd5\u5668<\/strong>\uff1a<code>pdb<\/code>\u662fPython\u81ea\u5e26\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u5355\u6b65\u6267\u884c\u4ee3\u7801\uff0c\u68c0\u67e5\u53d8\u91cf\u503c\u548c\u7a0b\u5e8f\u72b6\u6001\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528IDE\u8c03\u8bd5\u529f\u80fd<\/strong>\uff1a\u5982\u679c\u4f7f\u7528PyCharm\u6216VSCode\u7b49IDE\uff0c\u53ef\u4ee5\u5229\u7528\u5176\u5185\u7f6e\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u8bbe\u7f6e\u65ad\u70b9\u3001\u89c2\u5bdf\u53d8\u91cf\u503c\u3001\u67e5\u770b\u8c03\u7528\u6808\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u5728Linux\u4e0a\u5f00\u53d1Python\u9700\u8981\u638c\u63e1\u4ece\u73af\u5883\u5b89\u88c5\u5230\u4ee3\u7801\u8c03\u8bd5\u7684\u4e00\u7cfb\u5217\u6280\u80fd\u3002\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u5de5\u5177\u3001\u719f\u6089Linux\u547d\u4ee4\u548cPython\u5e93\u7ba1\u7406\u3001\u638c\u63e1\u8c03\u8bd5\u6280\u5de7\uff0c\u8fd9\u4e9b\u90fd\u662f\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u7684\u5173\u952e\u3002\u901a\u8fc7\u4e0d\u65ad\u5b9e\u8df5\u548c\u63a2\u7d22\uff0c\u53ef\u4ee5\u9010\u6b65\u63d0\u9ad8Python\u5f00\u53d1\u6c34\u5e73\uff0c\u521b\u5efa\u51fa\u9ad8\u8d28\u91cf\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Linux\u7cfb\u7edf\u4e2d\u5b89\u88c5Python\u5f00\u53d1\u73af\u5883\uff1f<\/strong><br \/>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u5b89\u88c5Python\u5f00\u53d1\u73af\u5883\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b8c\u6210\u3002\u4f8b\u5982\uff0c\u5728Debian\u6216Ubuntu\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\u548c\u76f8\u5173\u5f00\u53d1\u5de5\u5177\uff1a  <\/p>\n<pre><code class=\"language-bash\">sudo apt update  \nsudo apt install python3 python3-pip python3-venv  \n<\/code><\/pre>\n<p>\u8fd9\u5c06\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python 3\u3001pip\uff08Python\u5305\u7ba1\u7406\u5de5\u5177\uff09\u4ee5\u53ca\u865a\u62df\u73af\u5883\u5de5\u5177\uff08venv\uff09\uff0c\u786e\u4fdd\u4f60\u5177\u5907\u5f00\u53d1Python\u5e94\u7528\u6240\u9700\u7684\u57fa\u7840\u73af\u5883\u3002<\/p>\n<p><strong>\u5728Linux\u4e0a\u5982\u4f55\u521b\u5efa\u548c\u7ba1\u7406Python\u865a\u62df\u73af\u5883\uff1f<\/strong><br \/>\u4f7f\u7528Python\u7684\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u4fdd\u6301\u4f9d\u8d56\u7684\u72ec\u7acb\u6027\u3002\u5728Linux\u4e0a\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\uff1a  <\/p>\n<ol>\n<li>\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u4f60\u7684\u9879\u76ee\u76ee\u5f55\u3002  <\/li>\n<li>\u4f7f\u7528\u547d\u4ee4<code>python3 -m venv myenv<\/code>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amyenv\u7684\u865a\u62df\u73af\u5883\u3002  <\/li>\n<li>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0c\u4f7f\u7528\u547d\u4ee4<code>source myenv\/bin\/activate<\/code>\u3002  <\/li>\n<li>\u5728\u6fc0\u6d3b\u7684\u73af\u5883\u4e2d\u5b89\u88c5\u6240\u9700\u7684Python\u5305\uff0c\u4f7f\u7528pip\u547d\u4ee4\uff0c\u5982<code>pip install requests<\/code>\u3002  <\/li>\n<li>\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>deactivate<\/code>\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ol>\n<p><strong>\u5728Linux\u4e0a\u5982\u4f55\u8c03\u8bd5Python\u4ee3\u7801\uff1f<\/strong><br \/>\u8c03\u8bd5Python\u4ee3\u7801\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u5de5\u5177\u548c\u65b9\u6cd5\u3002\u5728Linux\u4e0a\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684pdb\u6a21\u5757\u8fdb\u884c\u8c03\u8bd5\u3002\u901a\u8fc7\u5728\u4ee3\u7801\u4e2d\u63d2\u5165<code>import pdb; pdb.set_trace()<\/code>\u6765\u8bbe\u7f6e\u65ad\u70b9\uff0c\u8fd0\u884c\u4ee3\u7801\u65f6\u7a0b\u5e8f\u5c06\u4f1a\u5728\u6b64\u5904\u6682\u505c\uff0c\u5141\u8bb8\u4f60\u68c0\u67e5\u53d8\u91cf\u3001\u6267\u884c\u8bed\u53e5\u7b49\u3002\u9664\u6b64\u4e4b\u5916\uff0cIDE\u5982PyCharm\u548cVS Code\u4e5f\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u6392\u67e5\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u4e0a\u5f00\u53d1Python\u7684\u5173\u952e\u8981\u7d20\u5305\u62ec\uff1a\u5b89\u88c5Python\u73af\u5883\u3001\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u5de5\u5177\u3001\u638c\u63e1\u57fa\u672c\u7684Linux\u547d [&hellip;]","protected":false},"author":3,"featured_media":1007173,"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\/1007161"}],"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=1007161"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1007161\/revisions"}],"predecessor-version":[{"id":1007180,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1007161\/revisions\/1007180"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1007173"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1007161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1007161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1007161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}