{"id":174120,"date":"2024-05-08T18:25:25","date_gmt":"2024-05-08T10:25:25","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/174120.html"},"modified":"2024-05-08T18:25:34","modified_gmt":"2024-05-08T10:25:34","slug":"%e5%88%b0%e5%ba%95%e8%af%a5%e5%a6%82%e4%bd%95%e8%bf%9b%e8%a1%8cpython%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/174120.html","title":{"rendered":"\u5230\u5e95\u8be5\u5982\u4f55\u8fdb\u884cpython\u73af\u5883\u914d\u7f6e"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27050243\/dbb0124d-389e-455b-bb0e-a7e0f9a2492e.webp\" alt=\"\u5230\u5e95\u8be5\u5982\u4f55\u8fdb\u884cpython\u73af\u5883\u914d\u7f6e\" \/><\/p>\n<p><p>\u8fdb\u884cPython\u73af\u5883\u914d\u7f6e\u4e3b\u8981\u5305\u62ec<strong>\u4e0b\u8f7d\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u4ee5\u53ca\u5229\u7528IDE\u5f00\u53d1<\/strong>\u3002\u8fd9\u4e9b\u6b65\u9aa4\u80fd\u591f\u786e\u4fddPython\u5f00\u53d1\u73af\u5883\u7684\u6b63\u786e\u642d\u5efa\u548c\u9ad8\u6548\u4f7f\u7528\u3002\u5728\u5176\u4e2d\uff0c<strong>\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\u662f\u5c24\u4e3a\u5173\u952e\u7684\u4e00\u6b65\u3002\u5b83\u4f7f\u5f97\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u8fd0\u884cPython\u548cpip\u6210\u4e3a\u53ef\u80fd\uff0c\u4ece\u800c\u6781\u5927\u5730\u63d0\u5347\u4e86\u5f00\u53d1\u7684\u4fbf\u6377\u6027\u3002\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6b63\u786e\u4e0e\u5426\uff0c\u76f4\u63a5\u5f71\u54cd\u5230Python\u7a0b\u5e8f\u7684\u8fd0\u884c\u548c\u7b2c\u4e09\u65b9\u5e93\u7684\u5b89\u88c5\u3002\u8fd9\u6d89\u53ca\u5230\u4e86\u5c06Python\u89e3\u91ca\u5668\u8def\u5f84\u548cpip\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u8fd9\u6837\u624d\u80fd\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u76f4\u63a5\u901a\u8fc7\u547d\u4ee4\u884c\u8c03\u7528Python\u548cpip\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4e0b\u8f7d\u5b89\u88c5PYTHON<\/h2>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u4e0e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5bf9\u5e94\u7684Python\u5b89\u88c5\u5305\u3002\u7f51\u7ad9\u63d0\u4f9b\u4e86\u4e0d\u540c\u7248\u672c\u7684Python\u4e0b\u8f7d\u9009\u9879\uff0c\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u4e0b\u8f7d\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u901a\u5e38\u662f\u6700\u4f73\u9009\u62e9\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u8bf7\u786e\u4fdd\u52fe\u9009\u4e86\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u4e2a\u64cd\u4f5c\u5c06\u4f1a\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u7b80\u5316\u540e\u7eed\u7684\u624b\u52a8\u8bbe\u7f6e\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165 <code>python --version<\/code> \u547d\u4ee4\u6765\u68c0\u67e5Python\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u5982\u679c\u7cfb\u7edf\u8fd4\u56de\u4e86Python\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8bf4\u660ePython\u5df2\u6b63\u786e\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h2>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5b89\u88c5Python\u7684\u8fc7\u7a0b\u4e2d\u6ca1\u6709\u52fe\u9009\u201cAdd Python to PATH\u201d\u7684\u9009\u9879\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u624b\u52a8\u6dfb\u52a0Python\u89e3\u91ca\u5668\u7684\u8def\u5f84\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u8fd9\u4e00\u6b65\u9aa4\u5bf9\u4e8eWindows\u7528\u6237\u5c24\u5176\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u627e\u5230Python\u5b89\u88c5\u7684\u8def\u5f84\uff0c\u8be5\u8def\u5f84\u5185\u4f1a\u5305\u542b\u7528\u4e8e\u6267\u884cPython\u547d\u4ee4\u7684<code>python.exe<\/code>\u6587\u4ef6\u3002\u7136\u540e\uff0c\u6253\u5f00\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\uff0c\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230\u201cPath\u201d\u53d8\u91cf\u4e2d\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u8ba9\u60a8\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u8c03\u7528Python\uff0c\u800c\u65e0\u9700\u8f93\u5165\u5b8c\u6574\u7684\u8def\u5f84\u540d\u3002<\/p>\n<\/p>\n<p><p>\u540c\u6837\uff0c\u786e\u4fdd\u5c06pip\u7684\u5b89\u88c5\u8def\u5f84\u4e5f\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u3002pip\u662fPython\u7684\u5305\u7ba1\u7406\u5668\uff0c\u901a\u8fc7\u5b83\u53ef\u4ee5\u5b89\u88c5\u548c\u7ba1\u7406\u7b2c\u4e09\u65b9Python\u5e93\u3002\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6b63\u786e\uff0c\u6781\u5927\u5730\u65b9\u4fbf\u4e86\u540e\u7eed\u7684Python\u5f00\u53d1\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662f\u8fdb\u884cPython\u5f00\u53d1\u7684\u6700\u4f73\u5b9e\u8df5\u4e4b\u4e00\u3002\u5b83\u5141\u8bb8\u60a8\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u4e00\u4e2a\u9694\u79bb\u7684Python\u8fd0\u884c\u73af\u5883\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u5e93\u7248\u672c\u51b2\u7a81\u3002<\/p>\n<\/p>\n<p><p>\u521b\u5efa\u865a\u62df\u73af\u5883\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u4f7f\u7528<code>python -m venv \u865a\u62df\u73af\u5883\u540d\u79f0<\/code>\u547d\u4ee4\u3002\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u65b9\u6cd5\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\u7565\u6709\u5dee\u5f02\uff0c\u4f46\u57fa\u672c\u539f\u5219\u662f\u8fd0\u884c\u865a\u62df\u73af\u5883\u76ee\u5f55\u4e0b\u7684\u6fc0\u6d3b\u811a\u672c\u3002<\/p>\n<\/p>\n<p><p>\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\u65f6\uff0c\u5b83\u4eec\u5c06\u88ab\u5b89\u88c5\u5728\u865a\u62df\u73af\u5883\u7684\u76ee\u5f55\u4e0b\uff0c\u800c\u4e0d\u662f\u5168\u5c40Python\u73af\u5883\u4e2d\uff0c\u8fd9\u6837\u6709\u6548\u907f\u514d\u4e86\u7248\u672c\u51b2\u7a81\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u5229\u7528IDE\u5f00\u53d1<\/h2>\n<\/p>\n<p><p>\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e3aPython\u5f00\u53d1\u63d0\u4f9b\u4e86\u6781\u5927\u7684\u4fbf\u5229\u3002\u5e38\u89c1\u7684Python IDE\u6709PyCharm\u3001Visual Studio Code\u7b49\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u4ee3\u7801\u9ad8\u4eae\u3001\u4ee3\u7801\u63d0\u793a\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\uff0c\u5927\u5927\u63d0\u9ad8\u4e86\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u81ea\u5df1\u7684IDE\uff0c\u7136\u540e\u6839\u636eIDE\u7684\u63d0\u793a\uff0c\u914d\u7f6e\u597dPython\u89e3\u91ca\u5668\u8def\u5f84\uff0c\u8fd9\u901a\u5e38\u6307\u5411\u60a8\u5b89\u88c5\u7684Python\u76ee\u5f55\u6216\u8005\u67d0\u4e2a\u9879\u76ee\u7684\u865a\u62df\u73af\u5883\u8def\u5f84\u3002\u786e\u4fddIDE\u80fd\u591f\u8bc6\u522b\u5e76\u4f7f\u7528\u6b63\u786e\u7684Python\u89e3\u91ca\u5668\uff0c\u662f\u786e\u4fdd\u5f00\u53d1\u987a\u5229\u8fdb\u884c\u7684\u91cd\u8981\u4e00\u73af\u3002<\/p>\n<\/p>\n<p><p>\u914d\u7f6e\u597d\u5f00\u53d1\u73af\u5883\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u4eab\u53d7Python\u7f16\u7a0b\u7684\u4e50\u8da3\u4e86\u3002\u901a\u8fc7\u865a\u62df\u73af\u5883\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u3001\u4f7f\u7528IDE\u63d0\u9ad8\u7f16\u7801\u6548\u7387\uff0cPython\u5f00\u53d1\u5c06\u53d8\u5f97\u8f7b\u677e\u6109\u5feb\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>Q: \u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e0a\u914d\u7f6ePython\u73af\u5883\uff1f<\/strong><br \/>\nA: Windows\u7cfb\u7edf\u4e0a\u914d\u7f6ePython\u73af\u5883\u6709\u51e0\u4e2a\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3002\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u7cfb\u7edf\u53d8\u91cf\u4e2d\u6dfb\u52a0Python\u8def\u5f84\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u76f4\u63a5\u8bbf\u95eePython\u3002\u6700\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u7f16\u8f91\u5668\u6765\u8bbe\u7f6ePython\u73af\u5883\uff0c\u4f8b\u5982\u9009\u62e9\u4f7f\u7528\u54ea\u4e2a\u7248\u672c\u7684Python\u4ee5\u53ca\u6dfb\u52a0\u5e93\u548c\u63d2\u4ef6\u3002<\/p>\n<p><strong>Q: \u5728Mac\u4e0a\u5982\u4f55\u914d\u7f6ePython\u73af\u5883\uff1f<\/strong><br \/>\nA: \u5728Mac\u4e0a\u914d\u7f6ePython\u73af\u5883\u4e5f\u5f88\u7b80\u5355\u3002\u9996\u5148\uff0c\u60a8\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3002\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u6dfb\u52a0Python\u8def\u5f84\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u8bbf\u95eePython\u3002\u6b64\u5916\uff0cMac\u4e0a\u901a\u5e38\u4f1a\u9884\u88c5Python 2.7\u7248\u672c\uff0c\u56e0\u6b64\u60a8\u9700\u8981\u786e\u4fdd\u6b63\u786e\u8bbe\u7f6e\u9ed8\u8ba4\u7684Python\u7248\u672c\u6216\u8005\u5b89\u88c5\u6240\u9700\u7684Python\u7248\u672c\u3002\u6700\u540e\uff0c\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91\u5668\u6765\u914d\u7f6ePython\u73af\u5883\uff0c\u4ee5\u4fbf\u66f4\u65b9\u4fbf\u5730\u5f00\u53d1\u548c\u8fd0\u884cPython\u7a0b\u5e8f\u3002<\/p>\n<p><strong>Q: \u5728Linux\u4e0a\u5982\u4f55\u914d\u7f6ePython\u73af\u5883\uff1f<\/strong><br \/>\nA: \u5728Linux\u4e0a\u914d\u7f6ePython\u73af\u5883\u901a\u5e38\u662f\u76f8\u5bf9\u7b80\u5355\u7684\u3002\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u90fd\u9884\u88c5\u4e86Python\uff0c\u56e0\u6b64\u60a8\u65e0\u9700\u624b\u52a8\u5b89\u88c5\u3002\u5982\u679c\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u4e0a\u53ef\u4ee5\u4f7f\u7528apt-get\u5b89\u88c5Python\u3002\u53e6\u5916\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6ePATH\u73af\u5883\u53d8\u91cf\u6765\u786e\u4fdd\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u76f4\u63a5\u8bbf\u95eePython\u3002\u5982\u679c\u9700\u8981\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u9694\u79bb\u9879\u76ee\uff0c\u53ef\u4ee5\u5b89\u88c5\u5e76\u4f7f\u7528virtualenv\u6216\u8005Anaconda\u7b49\u5de5\u5177\u3002\u6700\u540e\uff0c\u4f7f\u7528\u9002\u5408\u60a8\u7684\u559c\u597d\u7684\u7f16\u8f91\u5668\u6765\u914d\u7f6ePython\u73af\u5883\uff0c\u4ee5\u4fbf\u66f4\u9ad8\u6548\u5730\u8fdb\u884c\u5f00\u53d1\u548c\u8c03\u8bd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8fdb\u884cPython\u73af\u5883\u914d\u7f6e\u4e3b\u8981\u5305\u62ec\u4e0b\u8f7d\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u4ee5\u53ca\u5229\u7528IDE\u5f00\u53d1\u3002\u8fd9\u4e9b\u6b65\u9aa4 [&hellip;]","protected":false},"author":3,"featured_media":174134,"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\/174120"}],"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=174120"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/174120\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/174134"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=174120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=174120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=174120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}