{"id":950293,"date":"2024-12-27T00:31:36","date_gmt":"2024-12-26T16:31:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/950293.html"},"modified":"2024-12-27T00:31:38","modified_gmt":"2024-12-26T16:31:38","slug":"pycharm%e5%a6%82%e4%bd%95%e5%85%b3%e8%81%94python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/950293.html","title":{"rendered":"pycharm\u5982\u4f55\u5173\u8054python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25084941\/9ad8b1e6-ea55-4936-88ee-8efc684e289d.webp\" alt=\"pycharm\u5982\u4f55\u5173\u8054python\" \/><\/p>\n<p><p> <strong>\u8981\u5728PyCharm\u4e2d\u5173\u8054Python\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668\u3001\u521b\u5efa\u65b0\u9879\u76ee\u65f6\u9009\u62e9\u6b63\u786e\u7684\u89e3\u91ca\u5668\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u9879\u76ee\u9694\u79bb\u3001\u8bbe\u7f6e\u89e3\u91ca\u5668\u8def\u5f84\u3002<\/strong>\u5176\u4e2d\uff0c\u786e\u4fdd\u5df2\u5b89\u88c5Python\u89e3\u91ca\u5668\u662f\u6700\u4e3a\u91cd\u8981\u7684\u4e00\u6b65\u3002\u4ee5\u4e0b\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u8fdb\u884c\u8fd9\u4e00\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u786e\u4fdd\u5df2\u5b89\u88c5Python\u89e3\u91ca\u5668\u662f\u5173\u8054Python\u7684\u7b2c\u4e00\u6b65\u3002\u8981\u68c0\u67e5\u662f\u5426\u5df2\u7ecf\u5b89\u88c5Python\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u201cpython &#8211;version\u201d\u6216\u201cpython3 &#8211;version\u201d\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u7248\u672c\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u60a8\u9700\u8981\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5efa\u8bae\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u4ee5\u786e\u4fdd\u80fd\u591f\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u8bbf\u95eePython\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u786e\u4fdd\u5df2\u5b89\u88c5Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528PyCharm\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u786e\u4fdd\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u89e3\u91ca\u5668\u3002Python\u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\uff0cPyCharm\u662f\u4e00\u4e2a\u7528\u4e8ePython\u5f00\u53d1\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002\u786e\u8ba4\u662f\u5426\u5df2\u5b89\u88c5Python\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u68c0\u67e5Python\u7248\u672c<\/strong><br \/>\u5728Windows\u4e0a\uff0c\u60a8\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5728Mac\u548cLinux\u4e0a\uff0c\u60a8\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\u3002\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5Python\u7684\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e0a\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u770b\u5230Python\u7684\u7248\u672c\u53f7\uff0c\u90a3\u4e48\u8bf4\u660ePython\u5df2\u7ecf\u5b89\u88c5\u5728\u60a8\u7684\u7cfb\u7edf\u4e0a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong><br \/>\u5982\u679cPython\u672a\u5b89\u88c5\uff0c\u60a8\u9700\u8981\u4ece<a href=\"https:\/\/www.python.org\/\">Python\u5b98\u65b9\u7f51\u7ad9<\/a>\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3002\u6839\u636e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5408\u9002\u7684\u5b89\u88c5\u6587\u4ef6\uff0c\u5e76\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/strong><br \/>\u5b89\u88c5Python\u540e\uff0c\u5efa\u8bae\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u90fd\u53ef\u4ee5\u4f7f\u7528Python\u547d\u4ee4\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5728PyCharm\u4e2d\u5173\u8054Python\u7684\u4e0b\u4e00\u6b65\u662f\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002\u8fd9\u4e00\u6b65\u9aa4\u53ef\u4ee5\u786e\u4fddPyCharm\u80fd\u591f\u8bc6\u522b\u5e76\u4f7f\u7528\u60a8\u7684Python\u5b89\u88c5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00PyCharm<\/strong><br \/>\u542f\u52a8PyCharm\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u6b22\u8fce\u754c\u9762\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u89e3\u91ca\u5668<\/strong><br \/>\u5728\u6b22\u8fce\u754c\u9762\u4e2d\uff0c\u9009\u62e9\u201cConfigure\u201d &gt; \u201cSettings\u201d\u3002\u5728\u8bbe\u7f6e\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u201cProject: [Your Project Name]\u201d &gt; \u201cPython Interpreter\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u89e3\u91ca\u5668<\/strong><br \/>\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd&#8230;\u201d\uff0c\u7136\u540e\u9009\u62e9\u201cSystem Interpreter\u201d\u6216\u201cVirtual Environment\u201d\uff0c\u6839\u636e\u60a8\u7684\u9700\u8981\u8fdb\u884c\u9009\u62e9\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u786e\u8ba4\u89e3\u91ca\u5668\u8def\u5f84<\/strong><br \/>\u5728\u201cSystem Interpreter\u201d\u9009\u9879\u4e2d\uff0c\u6d4f\u89c8\u5e76\u9009\u62e9Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u786e\u8ba4\u9009\u62e9\u540e\uff0c\u70b9\u51fb\u201cOK\u201d\u5b8c\u6210\u914d\u7f6e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u521b\u5efa\u65b0\u9879\u76ee\u65f6\u9009\u62e9\u6b63\u786e\u7684\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u521b\u5efa\u65b0\u9879\u76ee\u65f6\uff0c\u786e\u4fdd\u9009\u62e9\u6b63\u786e\u7684Python\u89e3\u91ca\u5668\uff0c\u4ee5\u4fbf\u9879\u76ee\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u65b0\u9879\u76ee<\/strong><br \/>\u5728PyCharm\u6b22\u8fce\u754c\u9762\u4e2d\uff0c\u9009\u62e9\u201cCreate New Project\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u89e3\u91ca\u5668<\/strong><br \/>\u5728\u65b0\u9879\u76ee\u7a97\u53e3\u4e2d\uff0c\u60a8\u4f1a\u770b\u5230\u201cLocation\u201d\u548c\u201cInterpreter\u201d\u9009\u9879\u3002\u5728\u201cInterpreter\u201d\u4e0b\u62c9\u83dc\u5355\u4e2d\u9009\u62e9\u60a8\u5148\u524d\u914d\u7f6e\u7684Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b8c\u6210\u9879\u76ee\u521b\u5efa<\/strong><br \/>\u786e\u8ba4\u89e3\u91ca\u5668\u9009\u62e9\u65e0\u8bef\u540e\uff0c\u70b9\u51fb\u201cCreate\u201d\u6309\u94ae\u5b8c\u6210\u65b0\u9879\u76ee\u7684\u521b\u5efa\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u9879\u76ee\u9694\u79bb<\/p>\n<\/p>\n<p><p>\u5728Python\u9879\u76ee\u4e2d\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u5e93\u51b2\u7a81\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><br \/>\u5728PyCharm\u4e2d\uff0c\u60a8\u53ef\u4ee5\u5728\u521b\u5efa\u9879\u76ee\u65f6\u9009\u62e9\u201cNew environment using\u201d\u9009\u9879\uff0c\u7136\u540e\u9009\u62e9\u201cVirtualenv\u201d\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb<\/strong><br \/>\u4f7f\u7528\u865a\u62df\u73af\u5883\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684\u5e93\u800c\u4e0d\u5f71\u54cd\u5168\u5c40\u7684Python\u73af\u5883\u3002\u53ef\u4ee5\u901a\u8fc7PyCharm\u7684\u201cTerminal\u201d\u7a97\u53e3\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u6765\u7ba1\u7406\u4f9d\u8d56\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u8bbe\u7f6e\u89e3\u91ca\u5668\u8def\u5f84<\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728PyCharm\u4e2d\u9047\u5230\u89e3\u91ca\u5668\u8def\u5f84\u7684\u95ee\u9898\uff0c\u53ef\u4ee5\u624b\u52a8\u8bbe\u7f6e\u89e3\u91ca\u5668\u8def\u5f84\u4ee5\u786e\u4fdd\u9879\u76ee\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00\u9879\u76ee\u8bbe\u7f6e<\/strong><br \/>\u5728PyCharm\u4e2d\uff0c\u8fdb\u5165\u201cFile\u201d &gt; \u201cSettings\u201d\uff0c\u7136\u540e\u5bfc\u822a\u5230\u201cProject: [Your Project Name]\u201d &gt; \u201cPython Interpreter\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u624b\u52a8\u8bbe\u7f6e\u8def\u5f84<\/strong><br \/>\u5982\u679c\u89e3\u91ca\u5668\u8def\u5f84\u4e0d\u6b63\u786e\uff0c\u53ef\u4ee5\u624b\u52a8\u70b9\u51fb\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cShow All&#8230;\u201d\uff0c\u7136\u540e\u624b\u52a8\u7f16\u8f91\u89e3\u91ca\u5668\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u786e\u8ba4\u8bbe\u7f6e<\/strong><br \/>\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u201cOK\u201d\u4ee5\u4fdd\u5b58\u66f4\u6539\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5728PyCharm\u4e2d\u6210\u529f\u5173\u8054Python\u89e3\u91ca\u5668\uff0c\u5e76\u786e\u4fdd\u5728\u5f00\u53d1Python\u9879\u76ee\u65f6\u80fd\u591f\u987a\u5229\u8fd0\u884c\u4ee3\u7801\u3002PyCharm\u662f\u4e00\u4e2a\u5f3a\u5927\u7684IDE\uff0c\u914d\u5408\u6b63\u786e\u914d\u7f6e\u7684Python\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\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\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\uff08\u5728Mac\u4e0a\u662f\u201cPreferences\u201d\uff09\u3002\u5728\u5de6\u4fa7\u680f\u4e2d\uff0c\u627e\u5230\u201cProject: [\u4f60\u7684\u9879\u76ee\u540d]\u201d\uff0c\u7136\u540e\u9009\u62e9\u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u5df2\u6709\u7684\u89e3\u91ca\u5668\u6216\u8005\u6dfb\u52a0\u65b0\u7684\u89e3\u91ca\u5668\u3002\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd&#8230;\u201d\u6765\u6dfb\u52a0\u65b0\u7684Python\u73af\u5883\uff0c\u4f8b\u5982\u865a\u62df\u73af\u5883\u6216\u7cfb\u7edf\u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>\u5982\u4f55\u521b\u5efa\u865a\u62df\u73af\u5883\u5e76\u5728PyCharm\u4e2d\u4f7f\u7528\uff1f<\/strong><br \/>\u521b\u5efa\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u3002\u5728PyCharm\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u9879\u76ee\u8bbe\u7f6e\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u5728\u201cPython Interpreter\u201d\u8bbe\u7f6e\u9875\u9762\uff0c\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u201cAdd&#8230;\u201d\u6309\u94ae\uff0c\u9009\u62e9\u201cVirtualenv Environment\u201d\u3002\u63a5\u7740\uff0c\u9009\u62e9\u201cNew environment\u201d\u5e76\u6307\u5b9a\u8def\u5f84\uff0cPyCharm\u4f1a\u81ea\u52a8\u4e3a\u4f60\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u5f53\u524d\u9879\u76ee\u7684\u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728PyCharm\u4e2d\u5b89\u88c5Python\u5e93\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\u5b89\u88c5Python\u5e93\u975e\u5e38\u65b9\u4fbf\u3002\u5728\u201cPython Interpreter\u201d\u8bbe\u7f6e\u9875\u9762\u4e2d\uff0c\u4f60\u4f1a\u770b\u5230\u5df2\u5b89\u88c5\u7684\u5e93\u5217\u8868\u3002\u70b9\u51fb\u53f3\u4fa7\u7684\u201c+\u201d\u6309\u94ae\uff0c\u641c\u7d22\u4f60\u9700\u8981\u7684\u5e93\u540d\u79f0\uff0c\u7136\u540e\u9009\u62e9\u5e76\u70b9\u51fb\u201cInstall Package\u201d\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u7684\u5e93\u5c31\u4f1a\u51fa\u73b0\u5728\u5df2\u5b89\u88c5\u5217\u8868\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u9879\u76ee\u4e2d\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728PyCharm\u4e2d\u5173\u8054Python\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668\u3001\u521b\u5efa [&hellip;]","protected":false},"author":3,"featured_media":950296,"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\/950293"}],"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=950293"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/950293\/revisions"}],"predecessor-version":[{"id":950297,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/950293\/revisions\/950297"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/950296"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=950293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=950293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=950293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}