{"id":977197,"date":"2024-12-27T06:27:34","date_gmt":"2024-12-26T22:27:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/977197.html"},"modified":"2024-12-27T06:27:36","modified_gmt":"2024-12-26T22:27:36","slug":"pycharm%e4%b8%ad%e5%a6%82%e4%bd%95%e9%80%89%e6%8b%a9python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/977197.html","title":{"rendered":"pycharm\u4e2d\u5982\u4f55\u9009\u62e9python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24202548\/587a2449-83c2-4531-bbf5-2b4a23bc8b5d.webp\" alt=\"pycharm\u4e2d\u5982\u4f55\u9009\u62e9python\" \/><\/p>\n<p><p> <strong>\u5728PyCharm\u4e2d\u9009\u62e9Python\u89e3\u91ca\u5668\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u8bbe\u7f6e\u9879\u76ee\u89e3\u91ca\u5668\u3001\u521b\u5efa\u865a\u62df\u73af\u5883\u3001\u914d\u7f6e\u5168\u5c40\u89e3\u91ca\u5668<\/strong>\u3002\u8fd9\u4e9b\u65b9\u6cd5\u786e\u4fdd\u60a8\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u6b63\u786e\u7684Python\u7248\u672c\u548c\u5e93\u3002\u9996\u5148\uff0c\u60a8\u53ef\u4ee5\u5728\u9879\u76ee\u8bbe\u7f6e\u4e2d\u9009\u62e9\u6216\u6dfb\u52a0\u65b0\u7684Python\u89e3\u91ca\u5668\uff0c\u8fd9\u51b3\u5b9a\u4e86PyCharm\u5982\u4f55\u8fd0\u884c\u60a8\u7684Python\u4ee3\u7801\u3002\u5176\u6b21\uff0c\u521b\u5efa\u865a\u62df\u73af\u5883\u662f\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u5173\u7cfb\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u907f\u514d\u4e86\u4e0e\u7cfb\u7edfPython\u5e93\u7684\u51b2\u7a81\u3002\u6700\u540e\uff0c\u914d\u7f6e\u5168\u5c40\u89e3\u91ca\u5668\u9002\u7528\u4e8e\u591a\u4e2a\u9879\u76ee\u5171\u4eab\u540c\u4e00\u89e3\u91ca\u5668\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u9879\u76ee\u89e3\u91ca\u5668\u8bbe\u7f6e<\/h3>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u9879\u76ee\u89e3\u91ca\u5668\u662f\u5f00\u59cb\u5f00\u53d1\u9879\u76ee\u7684\u7b2c\u4e00\u6b65\u3002PyCharm\u5141\u8bb8\u60a8\u4e3a\u6bcf\u4e2a\u9879\u76ee\u9009\u62e9\u4e0d\u540c\u7684Python\u89e3\u91ca\u5668\uff0c\u4ee5\u786e\u4fdd\u9879\u76ee\u4f7f\u7528\u6b63\u786e\u7684Python\u7248\u672c\u548c\u5305\u3002<\/p>\n<\/p>\n<p><h4>1. \u8bbe\u7f6e\u9879\u76ee\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<ul>\n<li>\u6253\u5f00PyCharm\u5e76\u52a0\u8f7d\u9879\u76ee\u3002<\/li>\n<li>\u8fdb\u5165\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\uff08\u5bf9\u4e8eWindows\u548cLinux\uff09\u6216\u201cPreferences\u201d\uff08\u5bf9\u4e8emacOS\uff09\u3002<\/li>\n<li>\u5728\u5de6\u4fa7\u9762\u677f\u4e2d\uff0c\u5c55\u5f00\u201cProject: [Your_Project_Name]\u201d\uff0c\u9009\u62e9\u201cPython Interpreter\u201d\u3002<\/li>\n<li>\u5728\u53f3\u4fa7\uff0c\u60a8\u5c06\u770b\u5230\u5f53\u524d\u9879\u76ee\u7684Python\u89e3\u91ca\u5668\u3002\u70b9\u51fb\u8bbe\u7f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d\u3002<\/li>\n<li>\u9009\u62e9\u201cSystem Interpreter\u201d\u4ee5\u4f7f\u7528\u7cfb\u7edf\u4e0a\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u6216\u9009\u62e9\u201cVirtualenv Environment\u201d\u4ee5\u521b\u5efa\u65b0\u7684\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ul>\n<p><h4>2. \u68c0\u67e5\u548c\u66f4\u6539\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<ul>\n<li>\u5728\u201cPython Interpreter\u201d\u9875\u9762\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u5df2\u5b89\u88c5\u7684\u5e93\u548c\u7248\u672c\u3002\u786e\u4fdd\u9009\u62e9\u7684\u89e3\u91ca\u5668\u7248\u672c\u4e0e\u9879\u76ee\u9700\u6c42\u76f8\u7b26\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u66f4\u6539\u89e3\u91ca\u5668\uff0c\u70b9\u51fb\u4e0b\u62c9\u83dc\u5355\uff0c\u9009\u62e9\u5176\u4ed6\u5df2\u914d\u7f6e\u7684\u89e3\u91ca\u5668\uff0c\u6216\u6309\u7167\u524d\u8ff0\u6b65\u9aa4\u6dfb\u52a0\u65b0\u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662fPython\u5f00\u53d1\u4e2d\u7684\u5173\u952e\u6982\u5ff5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u60a8\u9694\u79bb\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u7248\u672c\u51b2\u7a81\u3002<\/p>\n<\/p>\n<p><h4>1. \u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<ul>\n<li>\u5728\u8bbe\u7f6e\u9879\u76ee\u89e3\u91ca\u5668\u65f6\uff0c\u9009\u62e9\u201cVirtualenv Environment\u201d\u3002<\/li>\n<li>\u6307\u5b9a\u865a\u62df\u73af\u5883\u7684\u76ee\u5f55\uff0c\u901a\u5e38\u9009\u62e9\u9879\u76ee\u76ee\u5f55\u5185\u7684\u201cvenv\u201d\u6587\u4ef6\u5939\u3002<\/li>\n<li>\u9009\u62e9\u57fa\u7840Python\u89e3\u91ca\u5668\uff0cPyCharm\u5c06\u81ea\u52a8\u4e3a\u60a8\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/li>\n<li>\u521b\u5efa\u5b8c\u6210\u540e\uff0cPyCharm\u4f1a\u81ea\u52a8\u6fc0\u6d3b\u8be5\u865a\u62df\u73af\u5883\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u9879\u76ee\u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n<p><h4>2. \u7ba1\u7406\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<ul>\n<li>\u901a\u8fc7\u547d\u4ee4\u884c\u6216PyCharm\u7684\u7ec8\u7aef\u7a97\u53e3\uff0c\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u5b89\u88c5\u3001\u5347\u7ea7\u6216\u5220\u9664\u5305\u3002<\/li>\n<li>\u5728\u9879\u76ee\u7684\u201cPython Interpreter\u201d\u9875\u9762\uff0c\u76f4\u63a5\u67e5\u770b\u548c\u7ba1\u7406\u5df2\u5b89\u88c5\u7684\u5e93\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u5220\u9664\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u624b\u52a8\u5220\u9664\u201cvenv\u201d\u76ee\u5f55\uff0c\u5e76\u5728PyCharm\u4e2d\u91cd\u65b0\u914d\u7f6e\u9879\u76ee\u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u914d\u7f6e\u5168\u5c40\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u5e0c\u671b\u591a\u4e2a\u9879\u76ee\u5171\u4eab\u540c\u4e00\u4e2aPython\u89e3\u91ca\u5668\uff0c\u7279\u522b\u662f\u5f53\u8fd9\u4e9b\u9879\u76ee\u4e4b\u95f4\u6709\u76f8\u5173\u6027\u6216\u76f8\u4f3c\u7684\u4f9d\u8d56\u65f6\u3002<\/p>\n<\/p>\n<p><h4>1. \u8bbe\u7f6e\u5168\u5c40\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<ul>\n<li>\u5728\u201cPython Interpreter\u201d\u9875\u9762\uff0c\u901a\u8fc7\u201cAdd Interpreter\u201d\u9009\u62e9\u201cSystem Interpreter\u201d\u3002<\/li>\n<li>\u9009\u62e9\u7cfb\u7edf\u4e2d\u5df2\u6709\u7684Python\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<li>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u591a\u4e2a\u9879\u76ee\u4e2d\u4f7f\u7528\u8be5\u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n<p><h4>2. \u4f7f\u7528\u5168\u5c40\u89e3\u91ca\u5668\u7684\u6ce8\u610f\u4e8b\u9879<\/h4>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u5168\u5c40\u89e3\u91ca\u5668\u65f6\uff0c\u786e\u4fdd\u60a8\u7684\u9879\u76ee\u9700\u6c42\u4e0e\u5168\u5c40\u73af\u5883\u4e2d\u7684\u5e93\u7248\u672c\u517c\u5bb9\u3002<\/li>\n<li>\u907f\u514d\u5728\u5168\u5c40\u73af\u5883\u4e2d\u5b89\u88c5\u8fc7\u591a\u7684\u5e93\uff0c\u4ee5\u9632\u6b62\u5e93\u7248\u672c\u51b2\u7a81\u3002<\/li>\n<li>\u8003\u8651\u4e3a\u6838\u5fc3\u4f9d\u8d56\u5e93\u521b\u5efa\u5355\u72ec\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u4f7f\u7528\u8be5\u73af\u5883\u6765\u5f00\u53d1\u548c\u6d4b\u8bd5\u3002<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848<\/h3>\n<\/p>\n<p><p>\u5728PyCharm\u4e2d\u914d\u7f6ePython\u89e3\u91ca\u5668\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<p><h4>1. Python\u89e3\u91ca\u5668\u4e0d\u53ef\u7528<\/h4>\n<\/p>\n<ul>\n<li>\u786e\u4fdd\u5df2\u6b63\u786e\u5b89\u88c5Python\uff0c\u5e76\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u4e86\u8def\u5f84\u3002<\/li>\n<li>\u5728PyCharm\u4e2d\u68c0\u67e5\u89e3\u91ca\u5668\u8def\u5f84\u662f\u5426\u6b63\u786e\u3002<\/li>\n<li>\u91cd\u65b0\u521b\u5efa\u6216\u91cd\u65b0\u914d\u7f6e\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u5176\u5b8c\u6574\u6027\u3002<\/li>\n<\/ul>\n<p><h4>2. \u5e93\u7248\u672c\u51b2\u7a81<\/h4>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u865a\u62df\u73af\u5883\u9694\u79bb\u9879\u76ee\u4f9d\u8d56\uff0c\u907f\u514d\u4e0e\u5168\u5c40\u73af\u5883\u7684\u51b2\u7a81\u3002<\/li>\n<li>\u5b9a\u671f\u66f4\u65b0\u9879\u76ee\u4e2d\u7684\u201crequirements.txt\u201d\u6587\u4ef6\uff0c\u4ee5\u660e\u786e\u9879\u76ee\u6240\u9700\u7684\u5e93\u7248\u672c\u3002<\/li>\n<li>\u4f7f\u7528<code>pip freeze &gt; requirements.txt<\/code>\u547d\u4ee4\u751f\u6210\u5f53\u524d\u73af\u5883\u7684\u5e93\u7248\u672c\u5217\u8868\u3002<\/li>\n<\/ul>\n<p><h4>3. \u591a\u4e2aPython\u7248\u672c\u7ba1\u7406<\/h4>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u5de5\u5177\u5982<code>pyenv<\/code>\u6765\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u5e76\u5728\u9879\u76ee\u4e4b\u95f4\u5207\u6362\u3002<\/li>\n<li>\u5728PyCharm\u4e2d\u4e3a\u6bcf\u4e2a\u9879\u76ee\u9009\u62e9\u5408\u9002\u7684\u89e3\u91ca\u5668\u7248\u672c\uff0c\u786e\u4fdd\u517c\u5bb9\u6027\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u6b63\u786e\u914d\u7f6e\u548c\u7ba1\u7406Python\u89e3\u91ca\u5668\uff0c\u60a8\u53ef\u4ee5\u5728PyCharm\u4e2d\u9ad8\u6548\u5730\u5f00\u53d1Python\u9879\u76ee\u3002\u786e\u4fdd\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u5f97\u5230\u59a5\u5584\u7ba1\u7406\uff0c\u540c\u65f6\u4f7f\u7528\u865a\u62df\u73af\u5883\u63d0\u4f9b\u7684\u9694\u79bb\u7279\u6027\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u5347\u5f00\u53d1\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728PyCharm\u4e2d\u8bbe\u7f6ePython\u89e3\u91ca\u5668\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\u8bbe\u7f6ePython\u89e3\u91ca\u5668\u975e\u5e38\u7b80\u5355\u3002\u6253\u5f00\u4f60\u7684\u9879\u76ee\u540e\uff0c\u5bfc\u822a\u5230\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\uff08\u5728Mac\u4e0a\u4e3a\u201cPreferences\u201d\uff09\u3002\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u201cProject: [\u4f60\u7684\u9879\u76ee\u540d\u79f0]\u201d\u9009\u9879\uff0c\u70b9\u51fb\u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u6dfb\u52a0\u65b0\u7684\u89e3\u91ca\u5668\uff0c\u9009\u62e9\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u6216\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u9009\u62e9\u597d\u540e\uff0c\u70b9\u51fb\u201cOK\u201d\u4fdd\u5b58\u66f4\u6539\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u5728PyCharm\u4e2d\u6ca1\u6709\u770b\u5230\u6211\u60f3\u8981\u7684Python\u7248\u672c\uff0c\u5e94\u8be5\u600e\u4e48\u529e\uff1f<\/strong><br \/>\u5982\u679c\u5728PyCharm\u4e2d\u627e\u4e0d\u5230\u6240\u9700\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u68c0\u67e5\u8be5\u7248\u672c\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u5728\u7cfb\u7edf\u4e2d\u3002\u786e\u4fdd\u5728\u5b89\u88c5\u65f6\u9009\u62e9\u4e86\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3002\u4f60\u4e5f\u53ef\u4ee5\u624b\u52a8\u6dfb\u52a0Python\u89e3\u91ca\u5668\uff0c\u70b9\u51fb\u201cAdd Interpreter\u201d\uff0c\u9009\u62e9\u201cSystem Interpreter\u201d\uff0c\u7136\u540e\u6d4f\u89c8\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<p><strong>\u5728PyCharm\u4e2d\u5982\u4f55\u7ba1\u7406\u591a\u4e2aPython\u9879\u76ee\u7684\u89e3\u91ca\u5668\uff1f<\/strong><br \/>\u7ba1\u7406\u591a\u4e2aPython\u9879\u76ee\u7684\u89e3\u91ca\u5668\u975e\u5e38\u65b9\u4fbf\u3002\u5728\u6bcf\u4e2a\u9879\u76ee\u7684\u8bbe\u7f6e\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u9879\u76ee\u5355\u72ec\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002\u8fd9\u610f\u5473\u7740\u53ef\u4ee5\u4e3a\u4e0d\u540c\u7684\u9879\u76ee\u9009\u62e9\u4e0d\u540c\u7684Python\u7248\u672c\u6216\u865a\u62df\u73af\u5883\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4f9d\u8d56\u51b2\u7a81\u548c\u7248\u672c\u4e0d\u517c\u5bb9\u7684\u95ee\u9898\u3002\u6bcf\u6b21\u5207\u6362\u9879\u76ee\u65f6\uff0cPyCharm\u4f1a\u81ea\u52a8\u52a0\u8f7d\u8be5\u9879\u76ee\u5bf9\u5e94\u7684\u89e3\u91ca\u5668\u8bbe\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728PyCharm\u4e2d\u9009\u62e9Python\u89e3\u91ca\u5668\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u8bbe\u7f6e\u9879\u76ee\u89e3\u91ca\u5668\u3001\u521b\u5efa\u865a\u62df\u73af\u5883\u3001\u914d\u7f6e\u5168\u5c40\u89e3\u91ca\u5668\u3002\u8fd9\u4e9b\u65b9\u6cd5\u786e\u4fdd [&hellip;]","protected":false},"author":3,"featured_media":977204,"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\/977197"}],"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=977197"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/977197\/revisions"}],"predecessor-version":[{"id":977206,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/977197\/revisions\/977206"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/977204"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=977197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=977197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=977197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}