{"id":1178743,"date":"2025-01-15T18:14:35","date_gmt":"2025-01-15T10:14:35","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1178743.html"},"modified":"2025-01-15T18:14:38","modified_gmt":"2025-01-15T10:14:38","slug":"%e5%a6%82%e4%bd%95%e6%95%b4%e7%90%86python%e6%89%80%e6%9c%89%e5%ba%93%e5%ad%90","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1178743.html","title":{"rendered":"\u5982\u4f55\u6574\u7406python\u6240\u6709\u5e93\u5b50"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25113328\/96bf2299-c286-4a85-b1e2-8a3bffd6ce3f.webp\" alt=\"\u5982\u4f55\u6574\u7406python\u6240\u6709\u5e93\u5b50\" \/><\/p>\n<p><p> <strong>\u6574\u7406Python\u6240\u6709\u5e93\u5b50\u7684\u6b65\u9aa4\u53ef\u4ee5\u5305\u62ec\uff1a\u4e86\u89e3\u5e93\u7684\u5206\u7c7b\u3001\u4f7f\u7528\u5de5\u5177\u81ea\u52a8\u5316\u6574\u7406\u3001\u5b9a\u671f\u66f4\u65b0\u5e93\u5217\u8868\u3001\u5bf9\u5e93\u8fdb\u884c\u4f18\u5148\u7ea7\u5212\u5206<\/strong>\u3002\u5176\u4e2d\uff0c\u4e86\u89e3\u5e93\u7684\u5206\u7c7b\u662f\u5173\u952e\u4e00\u6b65\uff0c\u56e0\u4e3a\u5b83\u5e2e\u52a9\u4f60\u66f4\u6709\u6761\u7406\u5730\u7ba1\u7406\u548c\u9009\u62e9\u9700\u8981\u7684\u5e93\u3002Python\u5e93\u53ef\u4ee5\u6309\u7167\u529f\u80fd\u5206\u4e3a\u79d1\u5b66\u8ba1\u7b97\u5e93\u3001\u6570\u636e\u5904\u7406\u5e93\u3001Web\u5f00\u53d1\u5e93\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u5e93\u7b49\u3002\u901a\u8fc7\u8fd9\u79cd\u5206\u7c7b\uff0c\u4f60\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u627e\u5230\u5e76\u4f7f\u7528\u5408\u9002\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e86\u89e3\u5e93\u7684\u5206\u7c7b<\/h3>\n<\/p>\n<p><p>\u4e86\u89e3Python\u5e93\u7684\u5206\u7c7b\u662f\u6574\u7406\u6240\u6709\u5e93\u7684\u7b2c\u4e00\u6b65\uff0c\u8fd9\u6709\u52a9\u4e8e\u4f60\u6839\u636e\u9700\u6c42\u5feb\u901f\u627e\u5230\u5408\u9002\u7684\u5e93\u3002\u5e38\u89c1\u7684\u5206\u7c7b\u5305\u62ec\uff1a<\/p>\n<\/p>\n<p><h4>1. \u79d1\u5b66\u8ba1\u7b97\u5e93<\/h4>\n<\/p>\n<p><p>Python\u5728\u79d1\u5b66\u8ba1\u7b97\u9886\u57df\u6709\u8bb8\u591a\u5f3a\u5927\u7684\u5e93\u3002\u6700\u8457\u540d\u7684\u5305\u62ecNumPy\u3001SciPy\u548cPandas\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u5904\u7406\u548c\u8ba1\u7b97\u529f\u80fd\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>NumPy<\/strong>\uff1a\u4e3b\u8981\u7528\u4e8e\u6570\u7ec4\u548c\u77e9\u9635\u8fd0\u7b97\uff0c\u63d0\u4f9b\u4e86\u5927\u91cf\u6570\u5b66\u51fd\u6570\u3002<\/li>\n<li><strong>SciPy<\/strong>\uff1a\u57fa\u4e8eNumPy\uff0c\u6269\u5c55\u4e86\u66f4\u591a\u7684\u79d1\u5b66\u8ba1\u7b97\u529f\u80fd\uff0c\u5982\u79ef\u5206\u3001\u4f18\u5316\u3001\u4fe1\u53f7\u5904\u7406\u7b49\u3002<\/li>\n<li><strong>Pandas<\/strong>\uff1a\u4e3b\u8981\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u64cd\u4f5c\uff0c\u7279\u522b\u662f\u8868\u683c\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><h4>2. \u6570\u636e\u53ef\u89c6\u5316\u5e93<\/h4>\n<\/p>\n<p><p>\u6570\u636e\u53ef\u89c6\u5316\u662f\u6570\u636e\u5206\u6790\u7684\u91cd\u8981\u90e8\u5206\uff0cPython\u6709\u51e0\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u53ef\u89c6\u5316\u5e93\uff0c\u5982Matplotlib\u3001Seaborn\u548cPlotly\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>Matplotlib<\/strong>\uff1a\u57fa\u7840\u7684\u7ed8\u56fe\u5e93\uff0c\u652f\u6301\u5404\u79cd\u7c7b\u578b\u7684\u56fe\u8868\u3002<\/li>\n<li><strong>Seaborn<\/strong>\uff1a\u57fa\u4e8eMatplotlib\uff0c\u63d0\u4f9b\u66f4\u9ad8\u7ea7\u7684\u6570\u636e\u53ef\u89c6\u5316\u63a5\u53e3\uff0c\u9002\u5408\u7edf\u8ba1\u6570\u636e\u7684\u7ed8\u5236\u3002<\/li>\n<li><strong>Plotly<\/strong>\uff1a\u652f\u6301\u4ea4\u4e92\u5f0f\u56fe\u8868\uff0c\u9002\u5408Web\u5e94\u7528\u548c\u52a8\u6001\u6570\u636e\u5c55\u793a\u3002<\/li>\n<\/ul>\n<p><h4>3. Web\u5f00\u53d1\u5e93<\/h4>\n<\/p>\n<p><p>Python\u5728Web\u5f00\u53d1\u65b9\u9762\u4e5f\u6709\u8bb8\u591a\u6d41\u884c\u7684\u5e93\u548c\u6846\u67b6\uff0c\u5982Django\u3001Flask\u548cPyramid\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>Django<\/strong>\uff1a\u4e00\u4e2a\u9ad8\u5c42\u6b21\u7684Web\u6846\u67b6\uff0c\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5305\u62ecORM\u3001\u6a21\u677f\u5f15\u64ce\u3001\u8868\u5355\u5904\u7406\u7b49\u3002<\/li>\n<li><strong>Flask<\/strong>\uff1a\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684Web\u6846\u67b6\uff0c\u7075\u6d3b\u6027\u9ad8\uff0c\u9002\u5408\u5c0f\u578b\u9879\u76ee\u548c\u5fae\u670d\u52a1\u3002<\/li>\n<li><strong>Pyramid<\/strong>\uff1a\u4ecb\u4e8eDjango\u548cFlask\u4e4b\u95f4\uff0c\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u81ea\u7531\u5ea6\u548c\u6269\u5c55\u6027\u3002<\/li>\n<\/ul>\n<p><h4>4. \u673a\u5668\u5b66\u4e60\u5e93<\/h4>\n<\/p>\n<p><p>\u673a\u5668\u5b66\u4e60\u662fPython\u7684\u4e00\u4e2a\u91cd\u8981\u5e94\u7528\u9886\u57df\uff0c\u6709\u8bb8\u591a\u77e5\u540d\u7684\u673a\u5668\u5b66\u4e60\u5e93\uff0c\u5982Scikit-learn\u3001TensorFlow\u548cKeras\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>Scikit-learn<\/strong>\uff1a\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u548c\u5de5\u5177\uff0c\u975e\u5e38\u9002\u5408\u5feb\u901f\u5f00\u53d1\u548c\u6d4b\u8bd5\u3002<\/li>\n<li><strong>TensorFlow<\/strong>\uff1a\u7531Google\u5f00\u53d1\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\uff0c\u529f\u80fd\u5f3a\u5927\uff0c\u9002\u5408\u5927\u89c4\u6a21\u673a\u5668\u5b66\u4e60\u4efb\u52a1\u3002<\/li>\n<li><strong>Keras<\/strong>\uff1a\u4e00\u4e2a\u9ad8\u5c42\u6b21\u7684\u795e\u7ecf\u7f51\u7edcAPI\uff0c\u80fd\u591f\u8fd0\u884c\u5728TensorFlow\u3001CNTK\u7b49\u57fa\u7840\u4e4b\u4e0a\uff0c\u6613\u4e8e\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u5de5\u5177\u81ea\u52a8\u5316\u6574\u7406<\/h3>\n<\/p>\n<p><p>\u624b\u52a8\u6574\u7406Python\u6240\u6709\u5e93\u53ef\u80fd\u975e\u5e38\u7e41\u7410\uff0c\u56e0\u6b64\u4f7f\u7528\u5de5\u5177\u8fdb\u884c\u81ea\u52a8\u5316\u6574\u7406\u662f\u4e00\u4e2a\u9ad8\u6548\u7684\u65b9\u6cd5\u3002\u5e38\u7528\u7684\u5de5\u5177\u548c\u65b9\u6cd5\u5305\u62ec\uff1a<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528Pip\u5de5\u5177<\/h4>\n<\/p>\n<p><p>Pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5b89\u88c5\u3001\u66f4\u65b0\u548c\u7ba1\u7406Python\u5e93\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5217\u51fa\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u663e\u793a\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\u53ca\u5176\u7248\u672c\u53f7\uff0c\u4f60\u53ef\u4ee5\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\u8fdb\u884c\u8fdb\u4e00\u6b65\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528Virtualenv\u548cPipenv<\/h4>\n<\/p>\n<p><p>Virtualenv\u548cPipenv\u662fPython\u7684\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u4eec\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u4e0d\u540c\u9879\u76ee\u4e2d\u9694\u79bb\u5e93\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u66f4\u597d\u5730\u7ba1\u7406\u548c\u6574\u7406\u5e93\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>Virtualenv<\/strong>\uff1a\u521b\u5efa\u865a\u62df\u73af\u5883\u5e76\u6fc0\u6d3b\u5b83\uff0c\u7136\u540e\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u6240\u9700\u7684\u5e93\u3002<\/li>\n<li><strong>Pipenv<\/strong>\uff1a\u7ed3\u5408\u4e86Pip\u548cVirtualenv\u7684\u529f\u80fd\uff0c\u63d0\u4f9b\u66f4\u9ad8\u7ea7\u7684\u4f9d\u8d56\u7ba1\u7406\u548c\u865a\u62df\u73af\u5883\u7ba1\u7406\u3002<\/li>\n<\/ul>\n<p><h4>3. \u81ea\u52a8\u5316\u811a\u672c<\/h4>\n<\/p>\n<p><p>\u4f60\u8fd8\u53ef\u4ee5\u7f16\u5199\u81ea\u52a8\u5316\u811a\u672c\uff0c\u4f7f\u7528Pip API\u6216\u76f4\u63a5\u89e3\u6790<code>pip list<\/code>\u7684\u8f93\u51fa\uff0c\u751f\u6210\u5e93\u7684\u5206\u7c7b\u548c\u6574\u7406\u62a5\u544a\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bPython\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<p>def get_installed_packages():<\/p>\n<p>    result = subprocess.run([&#39;pip&#39;, &#39;list&#39;], stdout=subprocess.PIPE)<\/p>\n<p>    packages = result.stdout.decode(&#39;utf-8&#39;).split(&#39;\\n&#39;)[2:]<\/p>\n<p>    return [pkg.split()[0] for pkg in packages if pkg]<\/p>\n<p>installed_packages = get_installed_packages()<\/p>\n<p>print(installed_packages)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u811a\u672c\u4f1a\u83b7\u53d6\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\uff0c\u5e76\u4ee5\u5217\u8868\u5f62\u5f0f\u8f93\u51fa\u3002\u4f60\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5bf9\u8fd9\u4e9b\u5e93\u8fdb\u884c\u5206\u7c7b\u548c\u6574\u7406\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5b9a\u671f\u66f4\u65b0\u5e93\u5217\u8868<\/h3>\n<\/p>\n<p><p>Python\u751f\u6001\u7cfb\u7edf\u4e0d\u65ad\u53d1\u5c55\uff0c\u65b0\u5e93\u4e0d\u65ad\u6d8c\u73b0\uff0c\u73b0\u6709\u5e93\u4e5f\u5728\u4e0d\u65ad\u66f4\u65b0\u3002\u56e0\u6b64\uff0c\u5b9a\u671f\u66f4\u65b0\u5e93\u5217\u8868\u662f\u4fdd\u8bc1\u6574\u7406\u5de5\u4f5c\u6709\u6548\u6027\u7684\u5173\u952e\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528Pip\u66f4\u65b0\u5e93<\/h4>\n<\/p>\n<p><p>\u5b9a\u671f\u4f7f\u7528Pip\u66f4\u65b0\u5df2\u5b89\u88c5\u7684\u5e93\uff0c\u786e\u4fdd\u4f60\u4f7f\u7528\u7684\u662f\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list --outdated<\/p>\n<p>pip install --upgrade &lt;package-name&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u81ea\u52a8\u5316\u66f4\u65b0\u811a\u672c<\/h4>\n<\/p>\n<p><p>\u7f16\u5199\u81ea\u52a8\u5316\u811a\u672c\uff0c\u5b9a\u671f\u68c0\u67e5\u548c\u66f4\u65b0\u5e93\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bPython\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<p>def update_packages():<\/p>\n<p>    result = subprocess.run([&#39;pip&#39;, &#39;list&#39;, &#39;--outdated&#39;], stdout=subprocess.PIPE)<\/p>\n<p>    outdated_packages = result.stdout.decode(&#39;utf-8&#39;).split(&#39;\\n&#39;)[2:]<\/p>\n<p>    for pkg in outdated_packages:<\/p>\n<p>        if pkg:<\/p>\n<p>            pkg_name = pkg.split()[0]<\/p>\n<p>            subprocess.run([&#39;pip&#39;, &#39;install&#39;, &#39;--upgrade&#39;, pkg_name])<\/p>\n<p>update_packages()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u811a\u672c\u4f1a\u81ea\u52a8\u68c0\u67e5\u5e76\u66f4\u65b0\u6240\u6709\u8fc7\u65f6\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5bf9\u5e93\u8fdb\u884c\u4f18\u5148\u7ea7\u5212\u5206<\/h3>\n<\/p>\n<p><p>\u5e76\u4e0d\u662f\u6240\u6709\u7684\u5e93\u90fd\u540c\u7b49\u91cd\u8981\uff0c\u5bf9\u5e93\u8fdb\u884c\u4f18\u5148\u7ea7\u5212\u5206\u6709\u52a9\u4e8e\u4f60\u66f4\u9ad8\u6548\u5730\u7ba1\u7406\u548c\u4f7f\u7528\u5b83\u4eec\u3002\u53ef\u4ee5\u6839\u636e\u4ee5\u4e0b\u51e0\u4e2a\u6807\u51c6\u8fdb\u884c\u4f18\u5148\u7ea7\u5212\u5206\uff1a<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528\u9891\u7387<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u5e93\u7684\u4f7f\u7528\u9891\u7387\u5212\u5206\u4f18\u5148\u7ea7\uff0c\u5e38\u7528\u7684\u5e93\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u9ad8\u4f18\u5148\u7ea7\uff0c\u5076\u5c14\u4f7f\u7528\u6216\u5907\u9009\u7684\u5e93\u8bbe\u7f6e\u4e3a\u4f4e\u4f18\u5148\u7ea7\u3002<\/p>\n<\/p>\n<p><h4>2. \u9879\u76ee\u4f9d\u8d56<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u5212\u5206\u4f18\u5148\u7ea7\uff0c\u9879\u76ee\u4e2d\u6838\u5fc3\u4f9d\u8d56\u7684\u5e93\u8bbe\u7f6e\u4e3a\u9ad8\u4f18\u5148\u7ea7\uff0c\u8f85\u52a9\u6027\u6216\u53ef\u66ff\u4ee3\u7684\u5e93\u8bbe\u7f6e\u4e3a\u4f4e\u4f18\u5148\u7ea7\u3002<\/p>\n<\/p>\n<p><h4>3. \u793e\u533a\u652f\u6301<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u5e93\u7684\u793e\u533a\u652f\u6301\u548c\u7ef4\u62a4\u60c5\u51b5\u5212\u5206\u4f18\u5148\u7ea7\uff0c\u6d3b\u8dc3\u7ef4\u62a4\u548c\u793e\u533a\u652f\u6301\u597d\u7684\u5e93\u8bbe\u7f6e\u4e3a\u9ad8\u4f18\u5148\u7ea7\uff0c\u53cd\u4e4b\u8bbe\u7f6e\u4e3a\u4f4e\u4f18\u5148\u7ea7\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u521b\u5efa\u5e93\u7684\u6587\u6863\u548c\u7b14\u8bb0<\/h3>\n<\/p>\n<p><p>\u6574\u7406\u5e93\u7684\u8fc7\u7a0b\u4e2d\uff0c\u521b\u5efa\u8be6\u7ec6\u7684\u6587\u6863\u548c\u7b14\u8bb0\u662f\u5f88\u6709\u5fc5\u8981\u7684\uff0c\u8fd9\u6709\u52a9\u4e8e\u4f60\u5feb\u901f\u4e86\u89e3\u548c\u4f7f\u7528\u8fd9\u4e9b\u5e93\u3002<\/p>\n<\/p>\n<p><h4>1. \u5e93\u7684\u7528\u9014\u548c\u529f\u80fd<\/h4>\n<\/p>\n<p><p>\u4e3a\u6bcf\u4e2a\u5e93\u521b\u5efa\u4e00\u4e2a\u7b80\u77ed\u7684\u4ecb\u7ecd\uff0c\u5305\u62ec\u5b83\u7684\u7528\u9014\u548c\u4e3b\u8981\u529f\u80fd\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>NumPy<\/strong>\uff1a\u7528\u4e8e\u6570\u7ec4\u548c\u77e9\u9635\u8fd0\u7b97\uff0c\u63d0\u4f9b\u4e86\u5927\u91cf\u6570\u5b66\u51fd\u6570\u3002<\/li>\n<li><strong>Pandas<\/strong>\uff1a\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u64cd\u4f5c\uff0c\u7279\u522b\u662f\u8868\u683c\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><h4>2. \u5b89\u88c5\u548c\u4f7f\u7528\u793a\u4f8b<\/h4>\n<\/p>\n<p><p>\u4e3a\u6bcf\u4e2a\u5e93\u63d0\u4f9b\u5b89\u88c5\u547d\u4ee4\u548c\u57fa\u672c\u4f7f\u7528\u793a\u4f8b\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b89\u88c5NumPy<\/strong>\uff1a\n<pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u4f7f\u7528NumPy<\/strong>\uff1a\n<pre><code class=\"language-python\">import numpy as np<\/p>\n<p>array = np.array([1, 2, 3])<\/p>\n<p>print(array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>3. \u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848<\/h4>\n<\/p>\n<p><p>\u8bb0\u5f55\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848\uff0c\u65b9\u4fbf\u65e5\u540e\u53c2\u8003\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>NumPy\u62a5\u9519\uff1aImportError: No module named numpy<\/strong><\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong>\uff1a\u68c0\u67e5\u662f\u5426\u6b63\u786e\u5b89\u88c5NumPy\uff0c\u5e76\u786e\u4fdd\u5b89\u88c5\u8def\u5f84\u5728Python\u8def\u5f84\u4e2d\u3002<\/li>\n<\/p>\n<\/ul>\n<p><h3>\u516d\u3001\u5b9a\u671f\u5ba1\u67e5\u548c\u4f18\u5316\u6574\u7406\u65b9\u6848<\/h3>\n<\/p>\n<p><p>\u6574\u7406Python\u5e93\u662f\u4e00\u4e2a\u52a8\u6001\u8fc7\u7a0b\uff0c\u9700\u8981\u5b9a\u671f\u5ba1\u67e5\u548c\u4f18\u5316\u6574\u7406\u65b9\u6848\uff0c\u4ee5\u786e\u4fdd\u5176\u6709\u6548\u6027\u548c\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b9a\u671f\u56de\u987e<\/h4>\n<\/p>\n<p><p>\u5b9a\u671f\u56de\u987e\u6574\u7406\u7684\u5e93\uff0c\u68c0\u67e5\u662f\u5426\u6709\u65b0\u7684\u5e93\u9700\u8981\u6dfb\u52a0\uff0c\u662f\u5426\u6709\u4e0d\u518d\u4f7f\u7528\u7684\u5e93\u9700\u8981\u79fb\u9664\uff0c\u4ee5\u53ca\u73b0\u6709\u5e93\u662f\u5426\u9700\u8981\u91cd\u65b0\u5206\u7c7b\u6216\u8c03\u6574\u4f18\u5148\u7ea7\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f18\u5316\u6574\u7406\u5de5\u5177<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u6574\u7406\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u95ee\u9898\u548c\u9700\u6c42\uff0c\u4e0d\u65ad\u4f18\u5316\u6574\u7406\u5de5\u5177\u548c\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u6539\u8fdb\u81ea\u52a8\u5316\u811a\u672c\uff0c\u589e\u52a0\u66f4\u591a\u529f\u80fd\u548c\u4f18\u5316\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h4>3. \u83b7\u53d6\u793e\u533a\u53cd\u9988<\/h4>\n<\/p>\n<p><p>\u79ef\u6781\u53c2\u4e0ePython\u793e\u533a\uff0c\u83b7\u53d6\u5176\u4ed6\u5f00\u53d1\u8005\u7684\u53cd\u9988\u548c\u5efa\u8bae\uff0c\u4e86\u89e3\u65b0\u7684\u6574\u7406\u65b9\u6cd5\u548c\u5de5\u5177\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u53c2\u52a0Python\u5f00\u53d1\u8005\u4f1a\u8bae\u3001\u52a0\u5165\u5728\u7ebf\u8bba\u575b\u6216\u8ba2\u9605\u76f8\u5173\u90ae\u4ef6\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5229\u7528\u5e93\u7ba1\u7406\u5e73\u53f0<\/h3>\n<\/p>\n<p><p>\u5229\u7528\u4e13\u95e8\u7684\u5e93\u7ba1\u7406\u5e73\u53f0\uff0c\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u6574\u7406\u548c\u7ba1\u7406Python\u5e93\u7684\u5de5\u4f5c\u3002\u8fd9\u4e9b\u5e73\u53f0\u901a\u5e38\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\u548c\u5de5\u5177\uff0c\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u7ba1\u7406\u5e93\u3002<\/p>\n<\/p>\n<p><h4>1. Anaconda<\/h4>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Python\u53d1\u884c\u7248\uff0c\u5305\u542b\u4e86\u8bb8\u591a\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684\u5e93\uff0c\u5e76\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5305\u7ba1\u7406\u548c\u73af\u5883\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>Conda<\/strong>\uff1aAnaconda\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5b89\u88c5\u3001\u66f4\u65b0\u548c\u7ba1\u7406Python\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5217\u51fa\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\uff1a\n<pre><code class=\"language-bash\">conda list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u73af\u5883\u7ba1\u7406<\/strong>\uff1aAnaconda\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u73af\u5883\u7ba1\u7406\u529f\u80fd\uff0c\u53ef\u4ee5\u521b\u5efa\u548c\u7ba1\u7406\u4e0d\u540c\u7684\u865a\u62df\u73af\u5883\uff0c\u65b9\u4fbf\u9694\u79bb\u5e93\u7684\u4f9d\u8d56\u5173\u7cfb\u3002<\/li>\n<\/ul>\n<p><h4>2. Poetry<\/h4>\n<\/p>\n<p><p>Poetry\u662f\u4e00\u4e2a\u73b0\u4ee3\u7684\u5305\u548c\u4f9d\u8d56\u7ba1\u7406\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\u548c\u66f4\u7b80\u6d01\u7684\u8bed\u6cd5\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u4f9d\u8d56\u7ba1\u7406<\/strong>\uff1aPoetry\u53ef\u4ee5\u81ea\u52a8\u89e3\u6790\u548c\u5b89\u88c5\u4f9d\u8d56\uff0c\u786e\u4fdd\u9879\u76ee\u4e2d\u7684\u5e93\u7248\u672c\u4e00\u81f4\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5217\u51fa\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\uff1a\n<pre><code class=\"language-bash\">poetry show<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong><a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a><\/strong>\uff1aPoetry\u63d0\u4f9b\u4e86\u66f4\u7b80\u6d01\u7684\u9879\u76ee\u7ba1\u7406\u5de5\u5177\uff0c\u65b9\u4fbf\u521b\u5efa\u548c\u7ba1\u7406Python\u9879\u76ee\u3002<\/li>\n<\/ul>\n<p><h3>\u516b\u3001\u603b\u7ed3\u4e0e\u5c55\u671b<\/h3>\n<\/p>\n<p><p>\u6574\u7406Python\u6240\u6709\u5e93\u662f\u4e00\u4e2a\u590d\u6742\u800c\u91cd\u8981\u7684\u4efb\u52a1\uff0c\u6d89\u53ca\u591a\u4e2a\u65b9\u9762\u7684\u5de5\u4f5c\u3002\u901a\u8fc7\u4e86\u89e3\u5e93\u7684\u5206\u7c7b\u3001\u4f7f\u7528\u5de5\u5177\u81ea\u52a8\u5316\u6574\u7406\u3001\u5b9a\u671f\u66f4\u65b0\u5e93\u5217\u8868\u3001\u5bf9\u5e93\u8fdb\u884c\u4f18\u5148\u7ea7\u5212\u5206\u3001\u521b\u5efa\u5e93\u7684\u6587\u6863\u548c\u7b14\u8bb0\u3001\u5b9a\u671f\u5ba1\u67e5\u548c\u4f18\u5316\u6574\u7406\u65b9\u6848\u4ee5\u53ca\u5229\u7528\u5e93\u7ba1\u7406\u5e73\u53f0\uff0c\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u5b8c\u6210\u8fd9\u4e00\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><p>\u672a\u6765\uff0c\u968f\u7740Python\u751f\u6001\u7cfb\u7edf\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u65b0\u7684\u5e93\u548c\u5de5\u5177\u5c06\u4e0d\u65ad\u6d8c\u73b0\uff0c\u6574\u7406\u5e93\u7684\u5de5\u4f5c\u4e5f\u5c06\u4e0d\u65ad\u6f14\u8fdb\u548c\u4f18\u5316\u3002\u79ef\u6781\u53c2\u4e0e\u793e\u533a\uff0c\u4fdd\u6301\u5b66\u4e60\u548c\u63a2\u7d22\uff0c\u662f\u4fdd\u6301\u6574\u7406\u5de5\u4f5c\u6709\u6548\u6027\u548c\u6548\u7387\u7684\u5173\u952e\u3002\u5e0c\u671b\u672c\u6587\u63d0\u4f9b\u7684\u65b9\u6cd5\u548c\u5efa\u8bae\u80fd\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u6574\u7406\u548c\u7ba1\u7406Python\u5e93\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u8d28\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u67e5\u770b\u6211\u5b89\u88c5\u7684\u6240\u6709Python\u5e93\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u6765\u67e5\u770b\u5f53\u524d\u73af\u5883\u4e2d\u5b89\u88c5\u7684\u6240\u6709Python\u5e93\u3002\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5217\u51fa\u5e93\u7684\u540d\u79f0\u53ca\u5176\u7248\u672c\u53f7\uff0c\u5e2e\u52a9\u60a8\u5feb\u901f\u4e86\u89e3\u6240\u5b89\u88c5\u7684\u5e93\u3002<\/p>\n<p><strong>\u5982\u4f55\u7ba1\u7406Python\u5e93\u7684\u7248\u672c\uff1f<\/strong><br \/>\u901a\u8fc7<code>pip install library_name==version_number<\/code>\u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684\u5e93\u3002\u5982\u679c\u9700\u8981\u66f4\u65b0\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip install --upgrade library_name<\/code>\u547d\u4ee4\u3002\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u7075\u6d3b\u5730\u7ba1\u7406\u5e93\u7684\u7248\u672c\uff0c\u786e\u4fdd\u9879\u76ee\u7684\u517c\u5bb9\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u5378\u8f7d\u4e0d\u518d\u9700\u8981\u7684Python\u5e93\uff1f<\/strong><br \/>\u4f7f\u7528<code>pip uninstall library_name<\/code>\u547d\u4ee4\u53ef\u4ee5\u8f7b\u677e\u5378\u8f7d\u4e0d\u518d\u9700\u8981\u7684\u5e93\u3002\u5728\u6267\u884c\u6b64\u64cd\u4f5c\u65f6\uff0c\u786e\u4fdd\u786e\u8ba4\u5e93\u7684\u540d\u79f0\uff0c\u4ee5\u907f\u514d\u610f\u5916\u5220\u9664\u91cd\u8981\u7684\u5e93\u3002\u4f7f\u7528<code>pip freeze<\/code>\u53ef\u4ee5\u5e2e\u52a9\u60a8\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684\u5e93\uff0c\u5e76\u9009\u62e9\u9700\u8981\u5378\u8f7d\u7684\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u6574\u7406Python\u6240\u6709\u5e93\u5b50\u7684\u6b65\u9aa4\u53ef\u4ee5\u5305\u62ec\uff1a\u4e86\u89e3\u5e93\u7684\u5206\u7c7b\u3001\u4f7f\u7528\u5de5\u5177\u81ea\u52a8\u5316\u6574\u7406\u3001\u5b9a\u671f\u66f4\u65b0\u5e93\u5217\u8868\u3001\u5bf9\u5e93\u8fdb\u884c\u4f18\u5148\u7ea7\u5212\u5206\u3002 [&hellip;]","protected":false},"author":3,"featured_media":1178750,"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\/1178743"}],"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=1178743"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1178743\/revisions"}],"predecessor-version":[{"id":1178751,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1178743\/revisions\/1178751"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1178750"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1178743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1178743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1178743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}