{"id":991993,"date":"2024-12-27T08:33:36","date_gmt":"2024-12-27T00:33:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/991993.html"},"modified":"2024-12-27T08:33:39","modified_gmt":"2024-12-27T00:33:39","slug":"pycharm%e5%a6%82%e4%bd%95%e6%94%b9%e5%8f%98python%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/991993.html","title":{"rendered":"pycharm\u5982\u4f55\u6539\u53d8python\u7248\u672c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25070033\/a44f9f85-79f8-4739-9abc-bf68ea6043fd.webp\" alt=\"pycharm\u5982\u4f55\u6539\u53d8python\u7248\u672c\" \/><\/p>\n<p><p> <strong>\u8981\u5728PyCharm\u4e2d\u6539\u53d8Python\u7248\u672c\uff0c\u9996\u5148\u9700\u8981\u521b\u5efa\u6216\u9009\u62e9\u4e00\u4e2a\u65b0\u7684Python\u89e3\u91ca\u5668\u3001\u8c03\u6574\u9879\u76ee\u8bbe\u7f6e\u5e76\u66f4\u65b0\u76f8\u5173\u4f9d\u8d56\u9879\u3002<\/strong>\u9996\u5148\uff0c<strong>\u521b\u5efa\u6216\u9009\u62e9\u65b0\u7684Python\u89e3\u91ca\u5668<\/strong>\u662f\u4e00\u79cd\u7b80\u5355\u800c\u76f4\u63a5\u7684\u65b9\u6cd5\uff0c\u5176\u6b21\u662f<strong>\u8c03\u6574\u9879\u76ee\u8bbe\u7f6e\u4ee5\u5339\u914d\u65b0\u7684\u89e3\u91ca\u5668<\/strong>\uff0c\u6700\u540e<strong>\u66f4\u65b0\u9879\u76ee\u4e2d\u6240\u6709\u76f8\u5173\u7684\u4f9d\u8d56\u9879<\/strong>\u4ee5\u786e\u4fdd\u517c\u5bb9\u6027\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u6267\u884c\u8fd9\u4e9b\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u521b\u5efa\u6216\u9009\u62e9\u65b0\u7684Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5728PyCharm\u4e2d\uff0cPython\u89e3\u91ca\u5668\u8d1f\u8d23\u6267\u884c\u4ee3\u7801\uff0c\u56e0\u6b64\u6539\u53d8Python\u7248\u672c\u7684\u7b2c\u4e00\u6b65\u662f\u9009\u62e9\u6216\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbf\u95ee\u9879\u76ee\u8bbe\u7f6e<\/strong>\uff1a\u6253\u5f00PyCharm\uff0c\u9009\u62e9\u60a8\u5f53\u524d\u7684\u9879\u76ee\uff0c\u70b9\u51fb\u9876\u90e8\u83dc\u5355\u4e2d\u7684\u201cFile\u201d\uff0c\u7136\u540e\u9009\u62e9\u201cSettings\u201d\uff08\u5728Mac\u4e0a\u662f\u201cPyCharm\u201d &gt; \u201cPreferences\u201d\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5bfc\u822a\u5230Python Interpreter<\/strong>\uff1a\u5728\u5de6\u4fa7\u5bfc\u822a\u680f\u4e2d\uff0c\u627e\u5230\u201cProject: [\u9879\u76ee\u540d\u79f0]\u201d\uff0c\u70b9\u51fb\u5c55\u5f00\uff0c\u7136\u540e\u9009\u62e9\u201cPython Interpreter\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0\u65b0\u7684\u89e3\u91ca\u5668<\/strong>\uff1a\u5728\u53f3\u4fa7\u9762\u677f\u4e2d\uff0c\u60a8\u5c06\u770b\u5230\u5f53\u524d\u4f7f\u7528\u7684\u89e3\u91ca\u5668\u3002\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u7136\u540e\u9009\u62e9\u201cAdd&#8230;\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u89e3\u91ca\u5668\u7c7b\u578b<\/strong>\uff1a\u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u4e0d\u540c\u7c7b\u578b\u7684\u89e3\u91ca\u5668\uff0c\u4f8b\u5982\u865a\u62df\u73af\u5883\u3001Conda\u73af\u5883\u3001\u7cfb\u7edf\u89e3\u91ca\u5668\u7b49\u3002\u9009\u62e9\u9002\u5408\u60a8\u9700\u6c42\u7684\u9009\u9879\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9Python\u7248\u672c<\/strong>\uff1a\u6839\u636e\u60a8\u7684\u9009\u62e9\uff0c\u60a8\u5c06\u80fd\u591f\u9009\u62e9\u6216\u4e0b\u8f7d\u6240\u9700\u7684Python\u7248\u672c\u3002\u5bf9\u4e8e\u7cfb\u7edf\u89e3\u91ca\u5668\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\uff1b\u5bf9\u4e8e\u865a\u62df\u73af\u5883\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u521b\u5efa\u65f6\u4f7f\u7528\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5e94\u7528\u66f4\u6539<\/strong>\uff1a\u9009\u62e9\u597d\u65b0\u7684\u89e3\u91ca\u5668\u540e\uff0c\u70b9\u51fb\u201cOK\u201d\u6216\u201cApply\u201d\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u8c03\u6574\u9879\u76ee\u8bbe\u7f6e\u4ee5\u5339\u914d\u65b0\u7684\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5728\u521b\u5efa\u6216\u9009\u62e9\u65b0\u7684\u89e3\u91ca\u5668\u4e4b\u540e\uff0c\u9700\u8981\u786e\u4fdd\u9879\u76ee\u8bbe\u7f6e\u5df2\u7ecf\u540c\u6b65\u66f4\u65b0\uff0c\u4ee5\u4fbf\u9879\u76ee\u80fd\u591f\u6b63\u786e\u8fd0\u884c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u786e\u8ba4\u89e3\u91ca\u5668\u66f4\u6539<\/strong>\uff1a\u8fd4\u56de\u5230\u201cSettings\u201d\u7a97\u53e3\u7684\u201cPython Interpreter\u201d\u90e8\u5206\uff0c\u786e\u4fdd\u5728\u201cInterpreter\u201d\u4e0b\u62c9\u83dc\u5355\u4e2d\u5df2\u7ecf\u9009\u62e9\u4e86\u65b0\u7684\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u66f4\u65b0\u9879\u76ee\u4f9d\u8d56<\/strong>\uff1a\u5982\u679c\u9879\u76ee\u4e2d\u4f7f\u7528\u4e86requirements.txt\u6216Pipfile\u7b49\u6587\u4ef6\u7ba1\u7406\u4f9d\u8d56\u9879\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u9879\u3002\u53ef\u4ee5\u4f7f\u7528PyCharm\u7684\u7ec8\u7aef\u6216\u5185\u7f6e\u5de5\u5177\u8fdb\u884c\u66f4\u65b0\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u9879\u76ee\u6587\u4ef6\u517c\u5bb9\u6027<\/strong>\uff1a\u5728\u66f4\u6539Python\u7248\u672c\u540e\uff0c\u67d0\u4e9b\u4ee3\u7801\u53ef\u80fd\u4e0d\u518d\u517c\u5bb9\u3002\u5efa\u8bae\u4f7f\u7528PyCharm\u7684\u4ee3\u7801\u68c0\u67e5\u5de5\u5177\u626b\u63cf\u9879\u76ee\u6587\u4ef6\u4ee5\u53d1\u73b0\u6f5c\u5728\u95ee\u9898\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u66f4\u65b0\u9879\u76ee\u4e2d\u6240\u6709\u76f8\u5173\u7684\u4f9d\u8d56\u9879<\/p>\n<\/p>\n<p><p>\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u9879\u4e0e\u65b0\u7684Python\u7248\u672c\u517c\u5bb9\u662f\u786e\u4fdd\u9879\u76ee\u987a\u5229\u8fd0\u884c\u7684\u91cd\u8981\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528pip\u66f4\u65b0\u4f9d\u8d56\u9879<\/strong>\uff1a\u6253\u5f00PyCharm\u7684\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\u4f9d\u8d56\u9879\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install -r requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pipenv install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fPipenv\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u51b3\u517c\u5bb9\u6027\u95ee\u9898<\/strong>\uff1a\u5728\u66f4\u6539Python\u7248\u672c\u540e\uff0c\u67d0\u4e9b\u5e93\u53ef\u80fd\u9700\u8981\u7279\u5b9a\u7248\u672c\u624d\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\u4f7f\u7528\u201cpip list\u201d\u6216\u201cpip freeze\u201d\u68c0\u67e5\u5df2\u5b89\u88c5\u5e93\u7684\u7248\u672c\uff0c\u5e76\u6839\u636e\u9700\u8981\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u6d4b\u8bd5<\/strong>\uff1a\u5982\u679c\u9879\u76ee\u4e2d\u6709\u5355\u5143\u6d4b\u8bd5\u6216\u96c6\u6210\u6d4b\u8bd5\uff0c\u8bf7\u8fd0\u884c\u5b83\u4eec\u4ee5\u786e\u4fdd\u6240\u6709\u529f\u80fd\u5728\u65b0\u7684Python\u7248\u672c\u4e0b\u6b63\u5e38\u5de5\u4f5c\u3002PyCharm\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684\u6d4b\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fd0\u884c\u548c\u8c03\u8bd5\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u603b\u7ed3\u4e0e\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<p><p>\u5728PyCharm\u4e2d\u6539\u53d8Python\u7248\u672c\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9700\u6c42\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u591a\u4e2a\u9879\u76ee\u6216\u8fc1\u79fb\u5230\u65b0\u7248\u672c\u7684Python\u65f6\u3002\u4e3a\u4e86\u987a\u5229\u5730\u5b8c\u6210\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5907\u4efd\u9879\u76ee<\/strong>\uff1a\u5728\u8fdb\u884c\u91cd\u5927\u66f4\u6539\u4e4b\u524d\uff0c\u5efa\u8bae\u5907\u4efd\u5f53\u524d\u9879\u76ee\uff0c\u4ee5\u9632\u6b62\u610f\u5916\u95ee\u9898\u5bfc\u81f4\u6570\u636e\u4e22\u5931\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5\u65b0\u7248\u672c<\/strong>\uff1a\u5728\u6b63\u5f0f\u5207\u6362\u5230\u65b0\u7684Python\u7248\u672c\u4e4b\u524d\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5206\u652f\u6216\u526f\u672c\u8fdb\u884c\u6d4b\u8bd5\uff0c\u4ee5\u8bc4\u4f30\u65b0\u7248\u672c\u7684\u5f71\u54cd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6ce8\u610f\u5f03\u7528\u529f\u80fd<\/strong>\uff1aPython\u7684\u6bcf\u4e2a\u65b0\u7248\u672c\u53ef\u80fd\u4f1a\u5f03\u7528\u4e00\u4e9b\u65e7\u529f\u80fd\u3002\u4ed4\u7ec6\u9605\u8bfbPython\u7248\u672c\u7684\u5b98\u65b9\u6587\u6863\u4ee5\u4e86\u89e3\u8fd9\u4e9b\u53d8\u5316\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5229\u7528\u793e\u533a\u8d44\u6e90<\/strong>\uff1a\u5982\u679c\u5728\u5347\u7ea7\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u53c2\u8003PyCharm\u7684\u5b98\u65b9\u6587\u6863\u3001\u793e\u533a\u8bba\u575b\u6216\u76f8\u5173\u535a\u5ba2\u6587\u7ae0\uff0c\u83b7\u53d6\u66f4\u591a\u5e2e\u52a9\u548c\u6307\u5bfc\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5728PyCharm\u4e2d\u987a\u5229\u66f4\u6539Python\u7248\u672c\uff0c\u5e76\u786e\u4fdd\u9879\u76ee\u5728\u65b0\u73af\u5883\u4e2d\u6b63\u5e38\u8fd0\u884c\u3002\u65e0\u8bba\u662f\u4e3a\u4e86\u5229\u7528\u65b0\u529f\u80fd\u8fd8\u662f\u4e3a\u4e86\u63d0\u9ad8\u517c\u5bb9\u6027\uff0c\u7406\u89e3\u548c\u5e94\u7528\u8fd9\u4e9b\u6280\u672f\u5c06\u6709\u52a9\u4e8e\u60a8\u5728\u5f00\u53d1\u4e2d\u66f4\u52a0\u9ad8\u6548\u548c\u4ece\u5bb9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728PyCharm\u4e2d\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u9879\u76ee\u8bbe\u7f6e\u6765\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\u3002\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\u6216\u201cPreferences\u201d\uff0c\u63a5\u7740\u5728\u5de6\u4fa7\u680f\u4e2d\u627e\u5230\u201cProject: [\u9879\u76ee\u540d\u79f0]\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u5c06\u770b\u5230\u5f53\u524d\u9879\u76ee\u6240\u4f7f\u7528\u7684Python\u7248\u672c\u548c\u53ef\u7528\u7684\u89e3\u91ca\u5668\u5217\u8868\u3002<\/p>\n<p><strong>\u66f4\u6539PyCharm\u4e2d\u7684Python\u7248\u672c\u4f1a\u5f71\u54cd\u5df2\u5b89\u88c5\u7684\u5e93\u5417\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u5207\u6362Python\u7248\u672c\u4f1a\u5f71\u54cd\u60a8\u5728\u8be5\u7248\u672c\u4e0b\u5b89\u88c5\u7684\u5e93\u3002\u6bcf\u4e2aPython\u7248\u672c\u6709\u5176\u72ec\u7acb\u7684\u5305\u7ba1\u7406\u73af\u5883\uff0c\u56e0\u6b64\u5728\u66f4\u6539\u7248\u672c\u65f6\uff0c\u60a8\u9700\u8981\u91cd\u65b0\u5b89\u88c5\u6240\u9700\u7684\u5e93\u548c\u4f9d\u8d56\u9879\uff0c\u4ee5\u786e\u4fdd\u5b83\u4eec\u4e0e\u65b0\u7684Python\u7248\u672c\u517c\u5bb9\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728PyCharm\u4e2d\u6dfb\u52a0\u65b0\u7684Python\u89e3\u91ca\u5668\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\u6dfb\u52a0\u65b0\u7684Python\u89e3\u91ca\u5668\u975e\u5e38\u7b80\u5355\u3002\u6253\u5f00\u201cSettings\u201d\u6216\u201cPreferences\u201d\u83dc\u5355\uff0c\u5bfc\u822a\u81f3\u201cProject: [\u9879\u76ee\u540d\u79f0]\u201d\u4e0b\u7684\u201cPython Interpreter\u201d\u9009\u9879\u3002\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd&#8230;\u201d\u9009\u9879\u3002\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u5df2\u6709\u7684\u89e3\u91ca\u5668\u3001\u521b\u5efa\u65b0\u7684\u865a\u62df\u73af\u5883\u6216\u914d\u7f6eDocker\u7b49\u5176\u4ed6\u73af\u5883\u3002\u5b8c\u6210\u540e\uff0c\u65b0\u7684\u89e3\u91ca\u5668\u5c06\u88ab\u6dfb\u52a0\u5230\u9879\u76ee\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728PyCharm\u4e2d\u6539\u53d8Python\u7248\u672c\uff0c\u9996\u5148\u9700\u8981\u521b\u5efa\u6216\u9009\u62e9\u4e00\u4e2a\u65b0\u7684Python\u89e3\u91ca\u5668\u3001\u8c03\u6574\u9879\u76ee\u8bbe\u7f6e\u5e76\u66f4\u65b0\u76f8\u5173 [&hellip;]","protected":false},"author":3,"featured_media":992001,"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\/991993"}],"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=991993"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/991993\/revisions"}],"predecessor-version":[{"id":992002,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/991993\/revisions\/992002"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/992001"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=991993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=991993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=991993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}