{"id":1071811,"date":"2025-01-08T11:10:37","date_gmt":"2025-01-08T03:10:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1071811.html"},"modified":"2025-01-08T11:10:40","modified_gmt":"2025-01-08T03:10:40","slug":"python%e5%ae%89%e8%a3%85%e5%90%8e%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1071811.html","title":{"rendered":"python\u5b89\u88c5\u540e\u5982\u4f55\u914d\u7f6e\u73af\u5883\u53d8\u91cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25102231\/220c2b62-f863-4876-9118-3533815da75b.webp\" alt=\"python\u5b89\u88c5\u540e\u5982\u4f55\u914d\u7f6e\u73af\u5883\u53d8\u91cf\" \/><\/p>\n<p><p> \u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u5b89\u88c5Python\u540e\u9700\u8981\u8fdb\u884c\u73af\u5883\u53d8\u91cf\u914d\u7f6e\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u5168\u5c40\u8bbf\u95eePython\u89e3\u91ca\u5668\u548c\u76f8\u5173\u5de5\u5177\u3002<strong>\u5b89\u88c5Python\u540e\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u6b65\u9aa4\uff1a\u627e\u5230Python\u5b89\u88c5\u8def\u5f84\u3001\u8bbe\u7f6e\u7cfb\u7edf\u53d8\u91cf\u3001\u6dfb\u52a0\u5230PATH\u73af\u5883\u53d8\u91cf<\/strong>\u3002\u4e0b\u9762\u8be6\u7ec6\u8bf4\u660e\u5176\u4e2d\u4e00\u4e2a\u6b65\u9aa4\u2014\u2014<strong>\u6dfb\u52a0\u5230PATH\u73af\u5883\u53d8\u91cf<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cPython\u4f1a\u5b89\u88c5\u5728C:\\Users\\YourUsername\\AppData\\Local\\Programs\\Python\\PythonXX\u6216\u8005C:\\PythonXX\uff08XX\u8868\u793aPython\u7248\u672c\u53f7\uff0c\u598239\u8868\u793aPython 3.9\uff09\u3002\u8bb0\u4f4f\u8fd9\u4e2a\u8def\u5f84\uff0c\u56e0\u4e3a\u6211\u4eec\u63a5\u4e0b\u6765\u9700\u8981\u5c06\u5176\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u627e\u5230Python\u5b89\u88c5\u8def\u5f84<\/h3>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u5f00\u59cb\u201d\u83dc\u5355\uff0c\u641c\u7d22\u201cPython\u201d\uff0c\u53f3\u952e\u70b9\u51fb\u201cPython\u201d\uff0c\u9009\u62e9\u201c\u6253\u5f00\u6587\u4ef6\u4f4d\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u6587\u4ef6<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/58557.html\" target=\"_blank\">\u8d44\u6e90\u7ba1\u7406<\/a>\u5668\u4e2d\u4f1a\u51fa\u73b0Python\u7684\u5feb\u6377\u65b9\u5f0f\uff0c\u518d\u6b21\u53f3\u952e\u70b9\u51fb\uff0c\u9009\u62e9\u201c\u6253\u5f00\u6587\u4ef6\u4f4d\u7f6e\u201d\u3002<\/li>\n<li>\u8fd9\u5c31\u662fPython\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u590d\u5236\u8fd9\u4e2a\u8def\u5f84\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u8bbe\u7f6e\u7cfb\u7edf\u53d8\u91cf<\/h3>\n<\/p>\n<ol>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u5728\u5de6\u4fa7\u680f\u4e2d\u9009\u62e9\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e0b\u7684\u201cPath\u201d\uff0c\u9009\u4e2d\u5b83\u5e76\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u6dfb\u52a0\u5230PATH\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<ol>\n<li>\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5c06\u4e4b\u524d\u590d\u5236\u7684Python\u5b89\u88c5\u8def\u5f84\u7c98\u8d34\u5230\u65b0\u5efa\u7684\u6761\u76ee\u4e2d\uff0c\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u3002<\/li>\n<li>\u56de\u5230\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\uff0c\u786e\u4fdd\u66f4\u6539\u5df2\u4fdd\u5b58\uff0c\u518d\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u3002<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u9a8c\u8bc1\u914d\u7f6e\u662f\u5426\u6210\u529f<\/h3>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\uff0c\u8f93\u5165 <code>python --version<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u5982\u679c\u663e\u793a\u51faPython\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u914d\u7f6e\u6210\u529f\u3002<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u8bbe\u7f6ePIP\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<ol>\n<li>\u540c\u6837\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\u3002<\/li>\n<li>\u6dfb\u52a0Python\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684Scripts\u5b50\u76ee\u5f55\u8def\u5f84\uff0c\u5982\uff1aC:\\Python39\\Scripts\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u5b89\u88c5Python\u5305<\/h3>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\uff0c\u8f93\u5165 <code>pip install \u5305\u540d<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u5982\u679c\u6210\u529f\u5b89\u88c5\uff0c\u8bf4\u660ePIP\u914d\u7f6e\u6210\u529f\u3002<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u914d\u7f6e\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<ol>\n<li>\u5b89\u88c5virtualenv\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u4e2d\u8f93\u5165 <code>pip install virtualenv<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u8f93\u5165 <code>virtualenv venv<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u4e2d\u8f93\u5165 <code>venv\\Scripts\\activate<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<\/ol>\n<p><h3>\u516b\u3001\u5347\u7ea7PIP\u548c\u5b89\u88c5\u5e38\u7528\u5305<\/h3>\n<\/p>\n<ol>\n<li>\u5347\u7ea7PIP\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u4e2d\u8f93\u5165 <code>python -m pip install --upgrade pip<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li>\u5b89\u88c5\u5e38\u7528\u5305\uff1a\u5982Numpy\u3001Pandas\u3001Matplotlib\u7b49\uff0c\u5728\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u4e2d\u8f93\u5165 <code>pip install numpy pandas matplotlib<\/code> \u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<\/ol>\n<p><h3>\u4e5d\u3001\u914d\u7f6eIDE<\/h3>\n<\/p>\n<ol>\n<li>\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e00\u4e2aIDE\uff0c\u5982PyCharm\u3001VS Code\u7b49\u3002<\/li>\n<li>\u5728IDE\u4e2d\u8bbe\u7f6ePython\u89e3\u91ca\u5668\u8def\u5f84\uff0c\u786e\u4fdd\u5176\u6307\u5411\u521a\u624d\u914d\u7f6e\u597d\u7684Python\u8def\u5f84\u3002<\/li>\n<li>\u914d\u7f6eLinting\u3001\u683c\u5f0f\u5316\u5de5\u5177\u7b49\uff0c\u4ee5\u4fbf\u63d0\u9ad8\u4ee3\u7801\u7f16\u5199\u6548\u7387\u3002<\/li>\n<\/ol>\n<p><h3>\u5341\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/h3>\n<\/p>\n<ol>\n<li><strong>Python\u8def\u5f84\u672a\u6dfb\u52a0\u6210\u529f<\/strong>\uff1a\u68c0\u67e5\u662f\u5426\u6b63\u786e\u590d\u5236\u548c\u7c98\u8d34\u4e86Python\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<li><strong>PIP\u672a\u914d\u7f6e\u6210\u529f<\/strong>\uff1a\u786e\u4fddScripts\u5b50\u76ee\u5f55\u8def\u5f84\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/li>\n<li><strong>\u547d\u4ee4\u63d0\u793a\u7b26\u65e0\u6cd5\u8bc6\u522bPython\u547d\u4ee4<\/strong>\uff1a\u91cd\u542f\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7cfb\u7edf\uff0c\u786e\u4fdd\u73af\u5883\u53d8\u91cf\u751f\u6548\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u60a8\u5df2\u7ecf\u6210\u529f\u914d\u7f6e\u4e86Python\u7684\u73af\u5883\u53d8\u91cf\uff0c\u5e76\u80fd\u591f\u5728\u547d\u4ee4\u884c\u4e2d\u5168\u5c40\u8bbf\u95eePython\u548cPIP\u3002\u914d\u7f6e\u865a\u62df\u73af\u5883\u548c\u5347\u7ea7PIP\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u9ad8\u6548\u5730\u7ba1\u7406Python\u9879\u76ee\u548c\u4f9d\u8d56\u5305\u3002\u914d\u7f6eIDE\u5219\u80fd\u591f\u663e\u8457\u63d0\u9ad8\u4ee3\u7801\u7f16\u5199\u548c\u8c03\u8bd5\u7684\u6548\u7387\u3002\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u9047\u5230\u4efb\u4f55\u95ee\u9898\uff0c\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u6587\u6863\u6216\u793e\u533a\u8d44\u6e90\u8fdb\u884c\u89e3\u51b3\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e0a\u914d\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\uff1f<\/strong><br \/>\u5728Windows\u4e0a\u914d\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\u76f8\u5bf9\u7b80\u5355\u3002\u9996\u5148\uff0c\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u901a\u5e38\u5728C:\\PythonXX\uff08XX\u4e3a\u7248\u672c\u53f7\uff09\u6216C:\\Users\\\u4f60\u7684\u7528\u6237\u540d\\AppData\\Local\\Programs\\Python\\PythonXX\u3002\u63a5\u4e0b\u6765\uff0c\u53f3\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002\u5728\u7cfb\u7edf\u5c5e\u6027\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u533a\u57df\uff0c\u627e\u5230\u201cPath\u201d\u53d8\u91cf\u5e76\u9009\u62e9\u201c\u7f16\u8f91\u201d\u3002\u5728\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u7a97\u53e3\u4e2d\uff0c\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\u53caScripts\u6587\u4ef6\u5939\u7684\u8def\u5f84\uff08\u5982C:\\PythonXX\\Scripts\uff09\uff0c\u6700\u540e\u4fdd\u5b58\u66f4\u6539\u5e76\u91cd\u542f\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5373\u53ef\u4f7f\u7528Python\u547d\u4ee4\u3002<\/p>\n<p><strong>\u5728Mac\u6216Linux\u7cfb\u7edf\u4e0a\u5982\u4f55\u8bbe\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\uff1f<\/strong><br \/>\u5bf9\u4e8eMac\u6216Linux\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539.bash_profile\u6216.bashrc\u6587\u4ef6\u6765\u8bbe\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982nano\u6216vim\uff09\u6253\u5f00.bash_profile\u6216.bashrc\u6587\u4ef6\uff0c\u6dfb\u52a0\u5982\u4e0b\u884c\uff1a<code>export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/code>\uff08\u8bf7\u5c06\u8def\u5f84\u66ff\u6362\u4e3a\u4f60Python\u7684\u5b9e\u9645\u5b89\u88c5\u8def\u5f84\uff09\u3002\u4fdd\u5b58\u6587\u4ef6\u540e\uff0c\u6267\u884c<code>source ~\/.bash_profile<\/code>\u6216<code>source ~\/.bashrc<\/code>\u547d\u4ee4\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002\u91cd\u65b0\u6253\u5f00\u7ec8\u7aef\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u4e86\u3002<\/p>\n<p><strong>\u5982\u679c\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u4e0d\u6b63\u786e\uff0c\u5982\u4f55\u68c0\u67e5\u5e76\u89e3\u51b3\u95ee\u9898\uff1f<\/strong><br \/>\u5982\u679c\u5728\u547d\u4ee4\u884c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u540e\u51fa\u73b0\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u7c7b\u4f3c\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u4e0d\u6b63\u786e\u3002\u9996\u5148\uff0c\u68c0\u67e5Python\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u4f7f\u7528<code>which python<\/code>\u6216<code>where python<\/code>\u547d\u4ee4\u6765\u786e\u8ba4\u5176\u5b89\u88c5\u8def\u5f84\u3002\u63a5\u7740\uff0c\u786e\u4fdd\u8be5\u8def\u5f84\u5df2\u6b63\u786e\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u8f93\u5165<code>echo $PATH<\/code>\uff08\u5728Linux\u548cMac\u4e0a\uff09\u6216<code>echo %PATH%<\/code>\uff08\u5728Windows\u4e0a\uff09\u6765\u67e5\u770b\u5f53\u524d\u7684PATH\u53d8\u91cf\u3002\u5982\u679c\u8def\u5f84\u7f3a\u5931\uff0c\u6309\u7167\u524d\u8ff0\u6b65\u9aa4\u91cd\u65b0\u6dfb\u52a0\uff0c\u5e76\u786e\u4fdd\u6ca1\u6709\u8f93\u5165\u9519\u8bef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u5b89\u88c5Python\u540e\u9700\u8981\u8fdb\u884c\u73af\u5883\u53d8\u91cf\u914d\u7f6e\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u5168\u5c40\u8bbf\u95eePython\u89e3\u91ca\u5668\u548c [&hellip;]","protected":false},"author":3,"featured_media":1071819,"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\/1071811"}],"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=1071811"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1071811\/revisions"}],"predecessor-version":[{"id":1071820,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1071811\/revisions\/1071820"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1071819"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1071811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1071811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1071811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}