{"id":1158544,"date":"2025-01-13T18:42:04","date_gmt":"2025-01-13T10:42:04","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1158544.html"},"modified":"2025-01-13T18:42:07","modified_gmt":"2025-01-13T10:42:07","slug":"%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%aepython%e7%9a%84%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1158544.html","title":{"rendered":"\u5982\u4f55\u8bbe\u7f6epython\u7684\u8def\u5f84"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25200441\/99c738c9-35aa-44ec-bf3b-fe06476aabde.webp\" alt=\"\u5982\u4f55\u8bbe\u7f6epython\u7684\u8def\u5f84\" \/><\/p>\n<p><p> \u8981\u8bbe\u7f6ePython\u7684\u8def\u5f84\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a<strong>\u4fee\u6539\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u914d\u7f6eIDE<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u4fee\u6539\u73af\u5883\u53d8\u91cf<\/strong>\u662f\u6700\u5e38\u89c1\u548c\u57fa\u7840\u7684\u65b9\u6cd5\u3002\u4fee\u6539\u73af\u5883\u53d8\u91cf\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5728Windows\u7cfb\u7edf\u4e2d<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u5e76\u9009\u62e9\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\u627e\u5230\u53d8\u91cf\u540d\u4e3a<code>Path<\/code>\u7684\u53d8\u91cf\uff0c\u9009\u4e2d\u5e76\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u5728\u53d8\u91cf\u503c\u672b\u5c3e\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff1a<code>C:\\Python39<\/code>\uff0c\u6ce8\u610f\u8def\u5f84\u4e4b\u95f4\u7528\u5206\u53f7\u9694\u5f00\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u5b8c\u6210\u8bbe\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5728MacOS\u548cLinux\u7cfb\u7edf\u4e2d<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165<code>nano ~\/.bash_profile<\/code>\u6216<code>nano ~\/.bashrc<\/code>\uff0c\u6839\u636e\u4f60\u4f7f\u7528\u7684shell\u7c7b\u578b\u9009\u62e9\u5408\u9002\u7684\u6587\u4ef6\u3002<\/li>\n<li>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\uff1a<code>export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/code>\uff0c\u5c06<code>\/usr\/local\/bin\/python3<\/code>\u66ff\u6362\u4e3a\u4f60\u7684Python\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\uff0c\u7136\u540e\u8f93\u5165<code>source ~\/.bash_profile<\/code>\u6216<code>source ~\/.bashrc<\/code>\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4fee\u6539\u73af\u5883\u53d8\u91cf\u662f\u4e00\u79cd\u5168\u5c40\u8bbe\u7f6e\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u6240\u6709\u9879\u76ee\u3002\u5728\u5177\u4f53\u9879\u76ee\u4e2d\uff0c\u4e3a\u4e86\u907f\u514d\u7248\u672c\u51b2\u7a81\uff0c\u63a8\u8350\u4f7f\u7528<strong>\u865a\u62df\u73af\u5883<\/strong>\u8fdb\u884c\u7ba1\u7406\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u4f1a\u8be6\u7ec6\u5c55\u5f00\u5982\u4f55\u8bbe\u7f6e\u865a\u62df\u73af\u5883\u548c\u914d\u7f6eIDE\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e00\u3001\u4fee\u6539\u73af\u5883\u53d8\u91cf<\/h2>\n<\/p>\n<p><h3>1. Windows\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u4fee\u6539\u73af\u5883\u53d8\u91cf\u662f\u6700\u5e38\u89c1\u7684\u8bbe\u7f6ePython\u8def\u5f84\u7684\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><h4>\u7b2c\u4e00\u6b65\uff1a\u6253\u5f00\u7cfb\u7edf\u5c5e\u6027<\/h4>\n<\/p>\n<p><p>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002\u5728\u6253\u5f00\u7684\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u5de6\u4fa7\u7684\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/p>\n<\/p>\n<p><h4>\u7b2c\u4e8c\u6b65\uff1a\u7f16\u8f91\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u9ad8\u7ea7\u201d\u9009\u9879\u5361\uff0c\u7136\u540e\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u53d8\u91cf\u540d\u4e3a<code>Path<\/code>\u7684\u53d8\u91cf\uff0c\u9009\u4e2d\u5e76\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/p>\n<\/p>\n<p><h4>\u7b2c\u4e09\u6b65\uff1a\u6dfb\u52a0Python\u8def\u5f84<\/h4>\n<\/p>\n<p><p>\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u7136\u540e\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u9ed8\u8ba4\u5b89\u88c5\u8def\u5f84\u53ef\u80fd\u662f<code>C:\\Python39<\/code>\u3002\u786e\u4fdd\u8def\u5f84\u4e4b\u95f4\u7528\u5206\u53f7\u9694\u5f00\uff0c\u4ee5\u514d\u8986\u76d6\u73b0\u6709\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h4>\u7b2c\u56db\u6b65\uff1a\u786e\u8ba4\u5e76\u4fdd\u5b58<\/h4>\n<\/p>\n<p><p>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u8bbe\u7f6e\uff0c\u5e76\u4f9d\u6b21\u5173\u95ed\u5404\u4e2a\u7a97\u53e3\u3002\u91cd\u65b0\u542f\u52a8\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python --version<\/code>\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u8bbe\u7f6ePython\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h3>2. MacOS\u548cLinux\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728MacOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539shell\u914d\u7f6e\u6587\u4ef6\u6765\u8bbe\u7f6ePython\u8def\u5f84\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><h4>\u7b2c\u4e00\u6b65\uff1a\u6253\u5f00\u7ec8\u7aef<\/h4>\n<\/p>\n<p><p>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165<code>nano ~\/.bash_profile<\/code>\u6216<code>nano ~\/.bashrc<\/code>\uff0c\u6839\u636e\u4f60\u4f7f\u7528\u7684shell\u7c7b\u578b\u9009\u62e9\u5408\u9002\u7684\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>\u7b2c\u4e8c\u6b65\uff1a\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\uff1a<code>export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/code>\uff0c\u5c06<code>\/usr\/local\/bin\/python3<\/code>\u66ff\u6362\u4e3a\u4f60\u7684Python\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u6bcf\u6b21\u542f\u52a8\u7ec8\u7aef\u65f6\uff0cPython\u8def\u5f84\u90fd\u4f1a\u88ab\u81ea\u52a8\u52a0\u8f7d\u3002<\/p>\n<\/p>\n<p><h4>\u7b2c\u4e09\u6b65\uff1a\u4fdd\u5b58\u5e76\u4f7f\u66f4\u6539\u751f\u6548<\/h4>\n<\/p>\n<p><p>\u6309<code>Ctrl + O<\/code>\u4fdd\u5b58\u6587\u4ef6\uff0c\u6309<code>Ctrl + X<\/code>\u9000\u51fa\u7f16\u8f91\u5668\u3002\u7136\u540e\u8f93\u5165<code>source ~\/.bash_profile<\/code>\u6216<code>source ~\/.bashrc<\/code>\u4f7f\u66f4\u6539\u751f\u6548\u3002\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python3 --version<\/code>\u547d\u4ee4\u6765\u9a8c\u8bc1\u8bbe\u7f6e\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662f\u4e00\u79cd\u9694\u79bb\u7684Python\u73af\u5883\uff0c\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u5728\u5f00\u53d1Python\u9879\u76ee\u65f6\uff0c\u63a8\u8350\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><h3>1. \u521b\u5efa\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><h4>\u4f7f\u7528venv\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u4ecePython 3.3\u7248\u672c\u5f00\u59cb\uff0cPython\u5185\u7f6e\u4e86<code>venv<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d\uff0c<code>myenv<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002\u547d\u4ee4\u6267\u884c\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u6587\u4ef6\u5939\uff0c\u5305\u542b\u865a\u62df\u73af\u5883\u7684\u6240\u6709\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>2. \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><h4>Windows\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\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>\u6fc0\u6d3b\u540e\uff0c\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u4f1a\u663e\u793a\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4f8b\u5982<code>(myenv)<\/code>\u3002<\/p>\n<\/p>\n<p><h4>MacOS\u548cLinux\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728MacOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\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><p>\u6fc0\u6d3b\u540e\uff0c\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u4f1a\u663e\u793a\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4f8b\u5982<code>(myenv)<\/code>\u3002<\/p>\n<\/p>\n<p><h3>3. \u5b89\u88c5\u4f9d\u8d56\u5305<\/h3>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u5305\u5c06\u4f1a\u5b89\u88c5\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u800c\u4e0d\u662f\u5168\u5c40\u73af\u5883\u4e2d\uff0c\u786e\u4fdd\u9879\u76ee\u4e4b\u95f4\u7684\u72ec\u7acb\u6027\u3002<\/p>\n<\/p>\n<p><h3>4. \u9000\u51fa\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u5b8c\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u9000\u51fa\u540e\uff0c\u547d\u4ee4\u884c\u63d0\u793a\u7b26\u4f1a\u6062\u590d\u5230\u9ed8\u8ba4\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u914d\u7f6eIDE<\/h2>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u65b9\u4fbf\u5730\u5f00\u53d1\u548c\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u53ef\u4ee5\u5728IDE\u4e2d\u914d\u7f6ePython\u8def\u5f84\u3002\u4ee5\u4e0b\u662f\u914d\u7f6e\u5e38\u7528IDE\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>1. PyCharm<\/h3>\n<\/p>\n<p><p>PyCharm\u662fJetBrains\u516c\u53f8\u5f00\u53d1\u7684\u4e00\u6b3e\u5f3a\u5927\u7684Python IDE\uff0c\u652f\u6301<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a>\u3001\u4ee3\u7801\u7f16\u8f91\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4>\u521b\u5efa\u65b0\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u6253\u5f00PyCharm\uff0c\u70b9\u51fb\u201cCreate New Project\u201d\u3002\u5728\u201cNew Project\u201d\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u9879\u76ee\u7c7b\u578b\u4e3a\u201cPure Python\u201d\uff0c\u5e76\u8bbe\u7f6e\u9879\u76ee\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h4>\u914d\u7f6e\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u5728\u201cProject Interpreter\u201d\u90e8\u5206\uff0c\u70b9\u51fb\u201cAdd Interpreter\u201d\u6309\u94ae\uff0c\u9009\u62e9\u201cSystem Interpreter\u201d\u6216\u201cVirtualenv Environment\u201d\u3002\u5982\u679c\u9009\u62e9\u865a\u62df\u73af\u5883\uff0c\u70b9\u51fb\u201cExisting environment\u201d\u9009\u9879\uff0c\u5e76\u6307\u5b9a\u865a\u62df\u73af\u5883\u7684\u8def\u5f84\u3002\u70b9\u51fb\u201cCreate\u201d\u5b8c\u6210\u9879\u76ee\u521b\u5efa\u3002<\/p>\n<\/p>\n<p><h3>2. Visual Studio Code<\/h3>\n<\/p>\n<p><p>Visual Studio Code\uff08\u7b80\u79f0VS Code\uff09\u662f\u5fae\u8f6f\u516c\u53f8\u5f00\u53d1\u7684\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u548c\u6269\u5c55\u3002<\/p>\n<\/p>\n<p><h4>\u5b89\u88c5Python\u6269\u5c55<\/h4>\n<\/p>\n<p><p>\u6253\u5f00VS Code\uff0c\u70b9\u51fb\u5de6\u4fa7\u7684\u6269\u5c55\u56fe\u6807\uff0c\u641c\u7d22\u5e76\u5b89\u88c5\u201cPython\u201d\u6269\u5c55\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u542fVS Code\u3002<\/p>\n<\/p>\n<p><h4>\u914d\u7f6e\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u5728VS Code\u4e2d\u6253\u5f00Python\u9879\u76ee\uff0c\u6309\u4e0b<code>Ctrl + Shift + P<\/code>\u5feb\u6377\u952e\uff0c\u8f93\u5165<code>Python: Select Interpreter<\/code>\u5e76\u56de\u8f66\u3002\u5728\u5f39\u51fa\u7684\u5217\u8868\u4e2d\uff0c\u9009\u62e9Python\u89e3\u91ca\u5668\u8def\u5f84\u3002\u5982\u679c\u9879\u76ee\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u9009\u62e9\u865a\u62df\u73af\u5883\u7684\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<p><h3>3. Jupyter Notebook<\/h3>\n<\/p>\n<p><p>Jupyter Notebook\u662f\u4e00\u6b3e\u652f\u6301\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u7684\u5de5\u5177\uff0c\u5e7f\u6cdb\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9886\u57df\u3002<\/p>\n<\/p>\n<p><h4>\u5b89\u88c5Jupyter<\/h4>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Jupyter\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install jupyter<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u542f\u52a8Jupyter Notebook<\/h4>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Jupyter Notebook\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">jupyter notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u6253\u5f00Jupyter Notebook\u754c\u9762\u3002\u5728\u754c\u9762\u4e2d\uff0c\u53ef\u4ee5\u521b\u5efa\u65b0\u7684Notebook\uff0c\u5e76\u9009\u62e9Python\u5185\u6838\u3002\u5982\u679c\u9879\u76ee\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u5728\u865a\u62df\u73af\u5883\u4e2d\u542f\u52a8Jupyter Notebook\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/h2>\n<\/p>\n<p><p>\u5728\u8bbe\u7f6ePython\u8def\u5f84\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u51e0\u4e2a\u5e38\u89c1\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>1. \u547d\u4ee4\u884c\u65e0\u6cd5\u8bc6\u522bPython\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>python<\/code>\u547d\u4ee4\u65f6\u51fa\u73b0\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u7c7b\u4f3c\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3aPython\u8def\u5f84\u672a\u6b63\u786e\u8bbe\u7f6e\u3002\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u4e2d\u662f\u5426\u5305\u542bPython\u8def\u5f84\uff0c\u5e76\u786e\u4fdd\u8def\u5f84\u62fc\u5199\u6b63\u786e\u3002<\/p>\n<\/p>\n<p><h3>2. Python\u7248\u672c\u51b2\u7a81<\/h3>\n<\/p>\n<p><p>\u5728\u540c\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c\u65f6\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u7248\u672c\u51b2\u7a81\u95ee\u9898\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u89e3\u51b3\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\uff0c\u786e\u4fdd\u6bcf\u4e2a\u9879\u76ee\u4f7f\u7528\u72ec\u7acb\u7684Python\u7248\u672c\u3002<\/li>\n<li>\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528<code>python3<\/code>\u6216<code>python2<\/code>\u547d\u4ee4\uff0c\u660e\u786e\u6307\u5b9aPython\u7248\u672c\u3002<\/li>\n<\/ul>\n<p><h3>3. IDE\u65e0\u6cd5\u8bc6\u522bPython\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u5728IDE\u4e2d\u65e0\u6cd5\u8bc6\u522bPython\u89e3\u91ca\u5668\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u89e3\u91ca\u5668\u8def\u5f84\u672a\u6b63\u786e\u914d\u7f6e\u3002\u68c0\u67e5IDE\u7684\u89e3\u91ca\u5668\u8bbe\u7f6e\uff0c\u786e\u4fdd\u8def\u5f84\u6307\u5411\u6b63\u786e\u7684Python\u5b89\u88c5\u76ee\u5f55\u6216\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h3>4. \u5b89\u88c5\u5305\u65f6\u51fa\u73b0\u6743\u9650\u95ee\u9898<\/h3>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Python\u5305\u65f6\uff0c\u5982\u679c\u51fa\u73b0\u6743\u9650\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u89e3\u51b3\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>pip install<\/code>\u547d\u4ee4\u65f6\uff0c\u6dfb\u52a0<code>--user<\/code>\u9009\u9879\uff0c\u5b89\u88c5\u5305\u5230\u7528\u6237\u76ee\u5f55\u3002\u4f8b\u5982\uff1a<code>pip install numpy --user<\/code>\u3002<\/li>\n<li>\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528<code>sudo<\/code>\u547d\u4ee4\uff0c\u4ee5\u7ba1\u7406\u5458\u6743\u9650\u8fd0\u884c<code>pip install<\/code>\u547d\u4ee4\u3002\u4f8b\u5982\uff1a<code>sudo pip install numpy<\/code>\u3002<\/li>\n<\/ul>\n<p><h2>\u4e94\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u8bbe\u7f6ePython\u8def\u5f84\u662fPython\u5f00\u53d1\u4e2d\u7684\u57fa\u7840\u64cd\u4f5c\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u548c\u914d\u7f6eIDE\u7b49\u65b9\u6cd5\u5b9e\u73b0\u3002\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u5177\u4f53\u6b65\u9aa4\u7565\u6709\u4e0d\u540c\uff0c\u4f46\u603b\u4f53\u601d\u8def\u4e00\u81f4\u3002\u901a\u8fc7\u6b63\u786e\u8bbe\u7f6ePython\u8def\u5f84\uff0c\u53ef\u4ee5\u786e\u4fddPython\u89e3\u91ca\u5668\u548c\u4f9d\u8d56\u5305\u7684\u6b63\u786e\u4f7f\u7528\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387\u548c\u9879\u76ee\u7ba1\u7406\u7684\u4fbf\u6377\u6027\u3002\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u63a8\u8350\u4f7f\u7528\u865a\u62df\u73af\u5883\u8fdb\u884c\u4f9d\u8d56\u7ba1\u7406\uff0c\u907f\u514d\u7248\u672c\u51b2\u7a81\u548c\u73af\u5883\u6c61\u67d3\u3002\u6b64\u5916\uff0c\u5728\u914d\u7f6eIDE\u65f6\uff0c\u786e\u4fdd\u9009\u62e9\u6b63\u786e\u7684Python\u89e3\u91ca\u5668\u8def\u5f84\uff0c\u4ee5\u4fbf\u5145\u5206\u5229\u7528IDE\u7684\u8c03\u8bd5\u548c\u5f00\u53d1\u529f\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e2d\u8bbe\u7f6ePython\u7684\u8def\u5f84\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8bbe\u7f6ePython\u7684\u8def\u5f84\u3002\u9996\u5148\uff0c\u627e\u5230Python\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u901a\u5e38\u662f\u5728<code>C:\\PythonXX<\/code>\uff08XX\u4e3a\u7248\u672c\u53f7\uff09\u3002\u63a5\u4e0b\u6765\uff0c\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u5e76\u9009\u4e2d\u201cPath\u201d\u53d8\u91cf\uff0c\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002\u5728\u7f16\u8f91\u7a97\u53e3\u4e2d\uff0c\u6dfb\u52a0Python\u7684\u5b89\u88c5\u76ee\u5f55\u548cScripts\u76ee\u5f55\uff08\u4f8b\u5982\uff0c<code>C:\\PythonXX<\/code>\u548c<code>C:\\PythonXX\\Scripts<\/code>\uff09\uff0c\u4fdd\u5b58\u540e\u5173\u95ed\u6240\u6709\u7a97\u53e3\u3002\u6700\u540e\uff0c\u91cd\u65b0\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165<code>python<\/code>\uff0c\u68c0\u67e5\u662f\u5426\u5df2\u6210\u529f\u8bbe\u7f6e\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728macOS\u4e2d\u914d\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\uff1f<\/strong><br \/>\u5728macOS\u4e2d\uff0c\u914d\u7f6ePython\u7684\u73af\u5883\u53d8\u91cf\u901a\u5e38\u6d89\u53ca\u5230\u4fee\u6539\u7ec8\u7aef\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982<code>nano<\/code>\u6216<code>vim<\/code>\uff09\u7f16\u8f91<code>~\/.bash_profile<\/code>\u6216<code>~\/.zshrc<\/code>\uff08\u5177\u4f53\u6587\u4ef6\u53d6\u51b3\u4e8e\u4f7f\u7528\u7684shell\uff09\u3002\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<code>export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/code>\uff08\u6839\u636e\u5b9e\u9645\u7684Python\u5b89\u88c5\u8def\u5f84\u8fdb\u884c\u4fee\u6539\uff09\u3002\u4fdd\u5b58\u540e\uff0c\u6267\u884c<code>source ~\/.bash_profile<\/code>\u6216<code>source ~\/.zshrc<\/code>\u4ee5\u5e94\u7528\u66f4\u6539\u3002\u8fd9\u6837\uff0c\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python3<\/code>\u65f6\uff0c\u7cfb\u7edf\u4fbf\u80fd\u627e\u5230Python\u3002<\/p>\n<p><strong>\u5982\u4f55\u9a8c\u8bc1Python\u8def\u5f84\u8bbe\u7f6e\u662f\u5426\u6210\u529f\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u9a8c\u8bc1Python\u8def\u5f84\u662f\u5426\u8bbe\u7f6e\u6210\u529f\u3002\u5982\u679c\u7cfb\u7edf\u6b63\u786e\u8fd4\u56dePython\u7684\u7248\u672c\u4fe1\u606f\uff0c\u8bf4\u660e\u8def\u5f84\u8bbe\u7f6e\u5df2\u6210\u529f\u3002\u5982\u679c\u51fa\u73b0\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u7c7b\u4f3c\u9519\u8bef\uff0c\u5219\u53ef\u80fd\u9700\u8981\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u662f\u5426\u6b63\u786e\u914d\u7f6e\uff0c\u6216\u91cd\u65b0\u542f\u52a8\u547d\u4ee4\u884c\u5de5\u5177\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002\u6b64\u5916\uff0c\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u8fd0\u884c\u7b80\u5355\u7684Python\u811a\u672c\uff0c\u786e\u4fddPython\u80fd\u591f\u6b63\u5e38\u6267\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u8bbe\u7f6ePython\u7684\u8def\u5f84\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4fee\u6539\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u914d\u7f6eIDE\u3002\u5176\u4e2d\uff0c\u4fee\u6539\u73af\u5883\u53d8\u91cf\u662f\u6700 [&hellip;]","protected":false},"author":3,"featured_media":1158550,"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\/1158544"}],"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=1158544"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1158544\/revisions"}],"predecessor-version":[{"id":1158552,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1158544\/revisions\/1158552"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1158550"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1158544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1158544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1158544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}