{"id":1163189,"date":"2025-01-15T14:52:17","date_gmt":"2025-01-15T06:52:17","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1163189.html"},"modified":"2025-01-15T14:52:20","modified_gmt":"2025-01-15T06:52:20","slug":"pycharm%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85python%e7%9a%84%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1163189.html","title":{"rendered":"pycharm\u5982\u4f55\u5b89\u88c5python\u7684\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25204020\/e5fcc147-03b6-4051-b970-6cf5aa090769.webp\" alt=\"pycharm\u5982\u4f55\u5b89\u88c5python\u7684\u5e93\" \/><\/p>\n<p><p> PyCharm\u5b89\u88c5Python\u5e93\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c<strong>\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a\u4f7f\u7528PyCharm\u81ea\u5e26\u7684Package Manager\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177pip\u3001\u4f7f\u7528Anaconda<\/strong>\u7b49\u3002\u4f7f\u7528PyCharm\u81ea\u5e26\u7684Package Manager\u662f\u6700\u4e3a\u76f4\u89c2\u548c\u65b9\u4fbf\u7684\u4e00\u79cd\u65b9\u6cd5\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u51e0\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528PyCharm\u81ea\u5e26\u7684Package Manager<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee<\/strong>\uff1a<\/p>\n<p>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u4f60\u6240\u9700\u8981\u5b89\u88c5\u5e93\u7684\u9879\u76ee\u3002\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u4e00\u4e2a\u9879\u76ee\uff0c\u53ef\u4ee5\u65b0\u5efa\u4e00\u4e2a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6253\u5f00\u9879\u76ee\u89e3\u91ca\u5668\u8bbe\u7f6e<\/strong>\uff1a<\/p>\n<p>\u5728PyCharm\u7684\u53f3\u4e0a\u89d2\u627e\u5230\u5e76\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u201cSettings\u201d\u3002\u5728\u5f39\u51fa\u7684\u8bbe\u7f6e\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u5de6\u4fa7\u680f\u4e2d\u7684\u201cProject: YourProjectName\u201d\uff0c\u7136\u540e\u9009\u62e9\u201cPython Interpreter\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u89e3\u91ca\u5668\u5e76\u7ba1\u7406\u5305<\/strong>\uff1a<\/p>\n<p>\u5728\u201cPython Interpreter\u201d\u9875\u9762\u4e2d\uff0c\u4f60\u5c06\u770b\u5230\u5f53\u524d\u9879\u76ee\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u3002\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Package\u201d\u3002\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u4f60\u53ef\u4ee5\u641c\u7d22\u4f60\u9700\u8981\u7684\u5e93\uff0c\u6bd4\u5982<code>numpy<\/code>\u3001<code>pandas<\/code>\u7b49\u3002\u627e\u5230\u540e\u70b9\u51fb\u201cInstall Package\u201d\u6309\u94ae\u5373\u53ef\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u786e\u8ba4\u5b89\u88c5<\/strong>\uff1a<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u201cInstalled Packages\u201d\u4e2d\u770b\u5230\u521a\u521a\u5b89\u88c5\u7684\u5e93\uff0c\u5e76\u53ef\u4ee5\u9009\u62e9\u67e5\u770b\u5176\u8be6\u7ec6\u4fe1\u606f\u6216\u5378\u8f7d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177pip<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00Terminal<\/strong>\uff1a<\/p>\n<p>\u5728PyCharm\u754c\u9762\u4e0b\u65b9\u627e\u5230\u5e76\u70b9\u51fb\u201cTerminal\u201d\u6807\u7b7e\uff0c\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pip\u5b89\u88c5\u5e93<\/strong>\uff1a<\/p>\n<p>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>pip install \u5e93\u540d<\/code>\uff0c\u4f8b\u5982\uff1a<code>pip install numpy<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u5373\u53ef\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u786e\u8ba4\u5b89\u88c5<\/strong>\uff1a<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165<code>pip list<\/code>\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u5217\u8868\uff0c\u786e\u8ba4\u4f60\u9700\u8981\u7684\u5e93\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528Anaconda<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Anaconda<\/strong>\uff1a<\/p>\n<p>\u9996\u5148\u4f60\u9700\u8981\u5728\u4f60\u7684\u7cfb\u7edf\u4e0a\u5b89\u88c5Anaconda\uff0c\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684Python\u53d1\u884c\u7248\uff0c\u5305\u542b\u4e86\u5927\u91cf\u7684\u6709\u7528\u5e93\u548c\u5de5\u5177\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u5e76\u6fc0\u6d3b\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Anaconda\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create -n myenv python=3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u6fc0\u6d3b\u8fd9\u4e2a\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u5e93<\/strong>\uff1a<\/p>\n<p>\u5728\u6fc0\u6d3b\u7684\u73af\u5883\u4e2d\u4f7f\u7528<code>conda install \u5e93\u540d<\/code>\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668<\/strong>\uff1a<\/p>\n<p>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee\u8bbe\u7f6e\uff0c\u9009\u62e9\u201cProject: YourProjectName\u201d -&gt; \u201cPython Interpreter\u201d\uff0c\u7136\u540e\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d -&gt; \u201cConda Environment\u201d\u3002\u9009\u62e9\u4f60\u4e4b\u524d\u521b\u5efa\u7684Anaconda\u73af\u5883\uff0c\u70b9\u51fb\u201cOK\u201d\u5373\u53ef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u4f60\u7684\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\\myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728MacOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u5e93<\/strong>\uff1a<\/p>\n<p>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\u4f7f\u7528<code>pip install \u5e93\u540d<\/code>\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668<\/strong>\uff1a<\/p>\n<p>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee\u8bbe\u7f6e\uff0c\u9009\u62e9\u201cProject: YourProjectName\u201d -&gt; \u201cPython Interpreter\u201d\uff0c\u7136\u540e\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d -&gt; \u201cExisting Environment\u201d\u3002\u9009\u62e9\u4f60\u4e4b\u524d\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u76ee\u5f55\u4e2d\u7684Python\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u70b9\u51fb\u201cOK\u201d\u5373\u53ef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u7cfb\u7edf\u5305\u7ba1\u7406\u5668<\/strong>\uff1a<\/p>\n<p>\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5b89\u88c5\u76f8\u5e94\u7684\u5305\u7ba1\u7406\u5668\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>apt<\/code>\uff0c\u5728MacOS\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>brew<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u5e93<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python3-numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668<\/strong>\uff1a<\/p>\n<p>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee\u8bbe\u7f6e\uff0c\u9009\u62e9\u201cProject: YourProjectName\u201d -&gt; \u201cPython Interpreter\u201d\uff0c\u7136\u540e\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d -&gt; \u201cSystem Interpreter\u201d\u3002\u9009\u62e9\u4f60\u7684\u7cfb\u7edfPython\u89e3\u91ca\u5668\uff0c\u70b9\u51fb\u201cOK\u201d\u5373\u53ef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5728PyCharm\u4e2d\u5b89\u88c5\u5e76\u7ba1\u7406Python\u5e93\u3002\u9009\u62e9\u6700\u9002\u5408\u4f60\u9879\u76ee\u9700\u6c42\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u548c<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a>\u7684\u4fbf\u6377\u6027\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u4ecb\u7ecd\u5404\u4e2a\u65b9\u6cd5\u7684\u5177\u4f53\u6b65\u9aa4\u548c\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528PyCharm\u81ea\u5e26\u7684Package Manager<\/h3>\n<\/p>\n<p><h4>1. \u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u542f\u52a8\u4f60\u7684PyCharm IDE\uff0c\u7136\u540e\u6253\u5f00\u4f60\u9700\u8981\u64cd\u4f5c\u7684\u9879\u76ee\u3002\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u521b\u5efa\u4e00\u4e2a\u9879\u76ee\uff0c\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u201cFile\u201d -&gt; \u201cNew Project\u201d\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9879\u76ee\u3002<\/p>\n<\/p>\n<p><h4>2. \u6253\u5f00\u9879\u76ee\u89e3\u91ca\u5668\u8bbe\u7f6e<\/h4>\n<\/p>\n<p><p>\u5728PyCharm\u7684\u53f3\u4e0a\u89d2\uff0c\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u201cSettings\u201d\u3002\u5728\u5f39\u51fa\u7684\u8bbe\u7f6e\u7a97\u53e3\u4e2d\uff0c\u5bfc\u822a\u5230\u201cProject: YourProjectName\u201d -&gt; \u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u4e2a\u9875\u9762\u4e2d\uff0c\u4f60\u5c06\u770b\u5230\u5f53\u524d\u9879\u76ee\u6240\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<p><h4>3. \u9009\u62e9\u89e3\u91ca\u5668\u5e76\u7ba1\u7406\u5305<\/h4>\n<\/p>\n<p><p>\u5728\u201cPython Interpreter\u201d\u9875\u9762\u4e2d\uff0c\u4f60\u5c06\u770b\u5230\u4e00\u4e2a\u5217\u8868\uff0c\u5217\u51fa\u4e86\u5f53\u524d\u9879\u76ee\u5df2\u5b89\u88c5\u7684\u5e93\u3002\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u7136\u540e\u9009\u62e9\u201cAdd Package\u201d\u3002\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u4f60\u53ef\u4ee5\u641c\u7d22\u5e76\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\u3002\u4f8b\u5982\uff0c\u8f93\u5165<code>numpy<\/code>\uff0c\u7136\u540e\u70b9\u51fb\u201cInstall Package\u201d\u3002<\/p>\n<\/p>\n<p><h4>4. \u786e\u8ba4\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u201cInstalled Packages\u201d\u4e2d\u770b\u5230\u4f60\u521a\u521a\u5b89\u88c5\u7684\u5e93\u3002\u70b9\u51fb\u5e93\u540d\u53ef\u4ee5\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7248\u672c\u3001\u4f9d\u8d56\u9879\u7b49\u3002\u5982\u679c\u9700\u8981\u5378\u8f7d\u5e93\uff0c\u53ef\u4ee5\u70b9\u51fb\u5e93\u540d\u53f3\u4fa7\u7684\u5783\u573e\u6876\u56fe\u6807\u8fdb\u884c\u5378\u8f7d\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177pip<\/h3>\n<\/p>\n<p><h4>1. \u6253\u5f00Terminal<\/h4>\n<\/p>\n<p><p>\u5728PyCharm\u754c\u9762\u4e0b\u65b9\uff0c\u70b9\u51fb\u201cTerminal\u201d\u6807\u7b7e\uff0c\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528pip\u5b89\u88c5\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><h4>3. \u786e\u8ba4\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u786e\u8ba4\u4f60\u9700\u8981\u7684\u5e93\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Anaconda<\/h3>\n<\/p>\n<p><h4>1. \u5b89\u88c5Anaconda<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5728\u4f60\u7684\u7cfb\u7edf\u4e0a\u5b89\u88c5Anaconda\uff0c\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684Python\u53d1\u884c\u7248\uff0c\u5305\u542b\u4e86\u5927\u91cf\u7684\u6709\u7528\u5e93\u548c\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4eceAnaconda\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5Anaconda\u3002<\/p>\n<\/p>\n<p><h4>2. \u521b\u5efa\u5e76\u6fc0\u6d3b\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Anaconda\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create -n myenv python=3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u6fc0\u6d3b\u8fd9\u4e2a\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u5b89\u88c5\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u7684\u73af\u5883\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4. \u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee\u8bbe\u7f6e\uff0c\u9009\u62e9\u201cProject: YourProjectName\u201d -&gt; \u201cPython Interpreter\u201d\uff0c\u7136\u540e\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d -&gt; \u201cConda Environment\u201d\u3002\u9009\u62e9\u4f60\u4e4b\u524d\u521b\u5efa\u7684Anaconda\u73af\u5883\uff0c\u70b9\u51fb\u201cOK\u201d\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><h4>1. \u521b\u5efa\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u4f60\u7684\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\\myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728MacOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u5b89\u88c5\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4. \u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee\u8bbe\u7f6e\uff0c\u9009\u62e9\u201cProject: YourProjectName\u201d -&gt; \u201cPython Interpreter\u201d\uff0c\u7136\u540e\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d -&gt; \u201cExisting Environment\u201d\u3002\u9009\u62e9\u4f60\u4e4b\u524d\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u76ee\u5f55\u4e2d\u7684Python\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u70b9\u51fb\u201cOK\u201d\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668<\/h3>\n<\/p>\n<p><h4>1. \u5b89\u88c5\u7cfb\u7edf\u5305\u7ba1\u7406\u5668<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5b89\u88c5\u76f8\u5e94\u7684\u5305\u7ba1\u7406\u5668\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>apt<\/code>\uff0c\u5728MacOS\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>brew<\/code>\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u5e93<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u7cfb\u7edf\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python3-numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u5728PyCharm\u4e2d\u914d\u7f6e\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee\u8bbe\u7f6e\uff0c\u9009\u62e9\u201cProject: YourProjectName\u201d -&gt; \u201cPython Interpreter\u201d\uff0c\u7136\u540e\u70b9\u51fb\u53f3\u4fa7\u7684\u9f7f\u8f6e\u56fe\u6807\uff0c\u9009\u62e9\u201cAdd Interpreter\u201d -&gt; \u201cSystem Interpreter\u201d\u3002\u9009\u62e9\u4f60\u7684\u7cfb\u7edfPython\u89e3\u91ca\u5668\uff0c\u70b9\u51fb\u201cOK\u201d\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u51e0\u79cd\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5728PyCharm\u4e2d\u5b89\u88c5\u5e76\u7ba1\u7406Python\u5e93\u3002\u9009\u62e9\u6700\u9002\u5408\u4f60\u9879\u76ee\u9700\u6c42\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u548c\u9879\u76ee\u7ba1\u7406\u7684\u4fbf\u6377\u6027\u3002\u5e0c\u671b\u8fd9\u4e9b\u65b9\u6cd5\u80fd\u5e2e\u52a9\u4f60\u987a\u5229\u5b89\u88c5\u548c\u7ba1\u7406Python\u5e93\uff0c\u63d0\u5347\u4f60\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728PyCharm\u4e2d\u5b89\u88c5Python\u5e93\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\u5b89\u88c5Python\u5e93\u975e\u5e38\u7b80\u5355\u3002\u53ef\u4ee5\u901a\u8fc7\u5185\u7f6e\u7684\u5305\u7ba1\u7406\u5de5\u5177\u6765\u5b9e\u73b0\u3002\u9996\u5148\uff0c\u6253\u5f00PyCharm\u5e76\u8fdb\u5165\u9879\u76ee\u754c\u9762\u3002\u63a5\u7740\uff0c\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\uff08\u5728Mac\u4e0a\u662f\u201cPreferences\u201d\uff09\u3002\u5728\u8bbe\u7f6e\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u201cProject: [\u4f60\u7684\u9879\u76ee\u540d]\u201d\u4e0b\u7684\u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u5df2\u5b89\u88c5\u7684\u5e93\u5217\u8868\uff0c\u70b9\u51fb\u53f3\u4fa7\u7684\u201c+\u201d\u53f7\uff0c\u641c\u7d22\u4f60\u9700\u8981\u7684\u5e93\uff0c\u9009\u62e9\u540e\u70b9\u51fb\u201cInstall Package\u201d\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u5728PyCharm\u4e2d\u5b89\u88c5\u5e93\uff1f<\/strong><br \/>\u7edd\u5bf9\u53ef\u4ee5\u3002\u5728PyCharm\u7684\u5e95\u90e8\u6709\u4e00\u4e2a\u201cTerminal\u201d\u7a97\u53e3\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u8f93\u5165\u547d\u4ee4\u884c\u6307\u4ee4\u3002\u4f8b\u5982\uff0c\u8981\u5b89\u88c5\u67d0\u4e2a\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip install package_name<\/code>\u547d\u4ee4\u3002\u786e\u4fdd\u4f60\u5728\u76f8\u5e94\u7684\u865a\u62df\u73af\u5883\u6216\u9879\u76ee\u73af\u5883\u4e2d\u6267\u884c\u8be5\u547d\u4ee4\uff0c\u4ee5\u786e\u4fdd\u5e93\u88ab\u6b63\u786e\u5b89\u88c5\u5230\u9879\u76ee\u4e2d\u3002<\/p>\n<p><strong>\u5728PyCharm\u4e2d\u5982\u4f55\u7ba1\u7406\u5df2\u5b89\u88c5\u7684\u5e93\uff1f<\/strong><br \/>\u7ba1\u7406\u5df2\u5b89\u88c5\u7684\u5e93\u540c\u6837\u65b9\u4fbf\u3002\u5728\u201cPython Interpreter\u201d\u8bbe\u7f6e\u9875\u9762\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u5217\u8868\u3002\u901a\u8fc7\u9009\u62e9\u67d0\u4e2a\u5e93\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\uff0c\u66f4\u65b0\u6216\u5378\u8f7d\u5b83\u3002\u5982\u679c\u9700\u8981\u6279\u91cf\u7ba1\u7406\u5e93\uff0c\u4e5f\u53ef\u4ee5\u8003\u8651\u4f7f\u7528requirements.txt\u6587\u4ef6\uff0cPyCharm\u652f\u6301\u4ece\u8be5\u6587\u4ef6\u4e2d\u5bfc\u5165\u4f9d\u8d56\u5e93\uff0c\u65b9\u4fbf\u7ba1\u7406\u9879\u76ee\u9700\u6c42\u3002<\/p>\n<p><strong>\u5b89\u88c5\u5e93\u540e\u5982\u4f55\u9a8c\u8bc1\u5b83\u4eec\u662f\u5426\u6b63\u5e38\u5de5\u4f5c\uff1f<\/strong><br \/>\u5b89\u88c5\u5e93\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728PyCharm\u4e2d\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u6765\u9a8c\u8bc1\u5b83\u4eec\u662f\u5426\u6b63\u5e38\u5de5\u4f5c\u3002\u5c1d\u8bd5\u5bfc\u5165\u521a\u5b89\u88c5\u7684\u5e93\u5e76\u8c03\u7528\u5176\u57fa\u672c\u529f\u80fd\u3002\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u9519\u8bef\u63d0\u793a\uff0c\u8bf4\u660e\u5e93\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u5e76\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u3002\u6b64\u5916\uff0cPyCharm\u4f1a\u81ea\u52a8\u63d0\u793a\u4ee3\u7801\u8865\u5168\uff0c\u5e2e\u52a9\u4f60\u4e86\u89e3\u5e93\u7684\u529f\u80fd\u548c\u7528\u6cd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"PyCharm\u5b89\u88c5Python\u5e93\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a\u4f7f\u7528PyCharm\u81ea\u5e26\u7684Package Man [&hellip;]","protected":false},"author":3,"featured_media":1163200,"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\/1163189"}],"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=1163189"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1163189\/revisions"}],"predecessor-version":[{"id":1163203,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1163189\/revisions\/1163203"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1163200"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1163189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1163189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1163189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}