{"id":975769,"date":"2024-12-27T06:15:59","date_gmt":"2024-12-26T22:15:59","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/975769.html"},"modified":"2024-12-27T06:16:00","modified_gmt":"2024-12-26T22:16:00","slug":"%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8bpython-%e7%9a%84%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/975769.html","title":{"rendered":"\u5982\u4f55\u67e5\u770bpython \u7684\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24200845\/09b13159-8417-40c7-a5fc-63d39148b56d.webp\" alt=\"\u5982\u4f55\u67e5\u770bpython \u7684\u5e93\" \/><\/p>\n<p><p> \u67e5\u770bPython\u5e93\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c<strong>\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u4f7f\u7528pip\u5de5\u5177\u3001\u5728Python\u89e3\u91ca\u5668\u4e2d\u4f7f\u7528help()\u51fd\u6570\u3001\u67e5\u770bPython\u5b98\u65b9\u6587\u6863\u6216\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e2d\u7684\u529f\u80fd\u6765\u67e5\u770b<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u901a\u8fc7pip\u5de5\u5177\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u3002pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5217\u51fa\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5\u7684\u6240\u6709Python\u5e93\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u51e0\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528PIP\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u4f7f\u7528pip\u5de5\u5177\u67e5\u770bPython\u5e93\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u901a\u8fc7\u547d\u4ee4\u884c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u5df2\u5b89\u88c5\u7684Python\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u547d\u4ee4\u5c06\u8f93\u51fa\u5f53\u524dPython\u73af\u5883\u4e2d\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\u53ca\u5176\u7248\u672c\u4fe1\u606f\u3002\u8fd9\u79cd\u65b9\u5f0f\u975e\u5e38\u9002\u5408\u4e8e\u5feb\u901f\u67e5\u770b\u5df2\u5b89\u88c5\u5e93\u7684\u6982\u51b5\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>pip show<\/code>\u547d\u4ee4\u67e5\u770b\u7279\u5b9a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip show numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793anumpy\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7248\u672c\u53f7\u3001\u5b89\u88c5\u4f4d\u7f6e\u3001\u4f9d\u8d56\u5173\u7cfb\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5728Python\u89e3\u91ca\u5668\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u67e5\u770b\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u9996\u5148\uff0c\u786e\u4fddPython\u89e3\u91ca\u5668\u5df2\u542f\u52a8\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy<\/p>\n<p>help(numpy)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793anumpy\u5e93\u7684\u5e2e\u52a9\u6587\u6863\uff0c\u5305\u62ec\u5176\u529f\u80fd\u3001\u6a21\u5757\u3001\u7c7b\u548c\u65b9\u6cd5\u3002\u8fd9\u79cd\u65b9\u5f0f\u9002\u5408\u4e8e\u5bf9\u67d0\u4e2a\u7279\u5b9a\u5e93\u8fdb\u884c\u6df1\u5165\u4e86\u89e3\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u67e5\u770bPython\u5b98\u65b9\u6587\u6863<\/p>\n<\/p>\n<p><p>Python\u5b98\u65b9\u6587\u6863\u662f\u83b7\u53d6\u5e93\u4fe1\u606f\u7684\u6743\u5a01\u6765\u6e90\u3002\u901a\u8fc7\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u53ef\u4ee5\u627e\u5230\u6240\u6709\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\u7684\u8be6\u7ec6\u6587\u6863\u3002\u8fd9\u4e9b\u6587\u6863\u901a\u5e38\u5305\u62ec\u5e93\u7684\u6982\u8ff0\u3001\u4f7f\u7528\u793a\u4f8b\u3001API\u53c2\u8003\u7b49\uff0c\u975e\u5e38\u9002\u5408\u4e8e\u521d\u5b66\u8005\u548c\u5f00\u53d1\u8005\u6df1\u5165\u5b66\u4e60\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/p>\n<\/p>\n<p><p>\u8bb8\u591aIDE\uff0c\u5982PyCharm\u3001VS Code\u7b49\uff0c\u63d0\u4f9b\u4e86\u67e5\u770b\u548c\u7ba1\u7406Python\u5e93\u7684\u529f\u80fd\u3002\u5728\u8fd9\u4e9bIDE\u4e2d\uff0c\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u56fe\u5f62\u754c\u9762\u7684\u5305\u7ba1\u7406\u5668\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\uff0c\u5e76\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u5b89\u88c5\u3001\u66f4\u65b0\u6216\u5378\u8f7d\u64cd\u4f5c\u3002\u6b64\u5916\uff0cIDE\u8fd8\u63d0\u4f9b\u4e86\u81ea\u52a8\u8865\u5168\u548c\u6587\u6863\u67e5\u770b\u529f\u80fd\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u4e86\u89e3\u5e93\u7684\u7528\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528Jupyter Notebook<\/p>\n<\/p>\n<p><p>Jupyter Notebook\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u4ea4\u4e92\u5f0f\u8ba1\u7b97\u73af\u5883\uff0c\u5c24\u5176\u5728\u6570\u636e\u79d1\u5b66\u9886\u57df\u3002\u901a\u8fc7\u5728Notebook\u5355\u5143\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">!pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u5f0f\u975e\u5e38\u9002\u5408\u4e8e\u6570\u636e\u5206\u6790\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9879\u76ee\uff0c\u56e0\u4e3a\u5b83\u5141\u8bb8\u5728\u540c\u4e00\u73af\u5883\u4e2d\u8fdb\u884c\u4ee3\u7801\u7f16\u5199\u3001\u6267\u884c\u548c\u7ed3\u679c\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u4f7f\u7528Conda\u73af\u5883<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f7f\u7528Anaconda\u4f5c\u4e3aPython\u7684\u53d1\u884c\u7248\uff0c\u53ef\u4ee5\u4f7f\u7528<code>conda<\/code>\u547d\u4ee4\u6765\u67e5\u770b\u5e93\u3002\u4e0epip\u7c7b\u4f3c\uff0c<code>conda list<\/code>\u547d\u4ee4\u53ef\u4ee5\u5217\u51faConda\u73af\u5883\u4e2d\u7684\u6240\u6709\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Conda\u8fd8\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u73af\u5883\u7ba1\u7406\u529f\u80fd\uff0c\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u3001\u514b\u9686\u548c\u7ba1\u7406\u4e0d\u540c\u7684Python\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p>\u4e03\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u67e5\u770bPython\u5e93\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<strong>\u4f7f\u7528pip\u5de5\u5177\u662f\u6700\u76f4\u63a5\u548c\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u800cIDE\u548cJupyter Notebook\u63d0\u4f9b\u4e86\u66f4\u4e3a\u53cb\u597d\u7684\u56fe\u5f62\u754c\u9762\u548c\u4ea4\u4e92\u5f0f\u529f\u80fd<\/strong>\u3002\u5bf9\u4e8e\u9700\u8981\u8be6\u7ec6\u5b66\u4e60\u67d0\u4e2a\u5e93\u7684\u5f00\u53d1\u8005\uff0cPython\u5b98\u65b9\u6587\u6863\u548c\u5e2e\u52a9\u51fd\u6570\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u8d44\u6e90\u3002\u6b64\u5916\uff0cConda\u73af\u5883\u7ba1\u7406\u5668\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u66f4\u4e3a\u7075\u6d3b\u548c\u5f3a\u5927\u7684\u73af\u5883\u7ba1\u7406\u529f\u80fd\u3002\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5168\u9762\u638c\u63e1Python\u5e93\u7684\u4f7f\u7528\u548c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u5e93\u7684\u7248\u672c\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u5e93\u7248\u672c\u3002\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>pip list<\/code>\uff0c\u8fd9\u5c06\u663e\u793a\u6240\u6709\u5df2\u5b89\u88c5\u5e93\u7684\u540d\u79f0\u53ca\u5176\u5bf9\u5e94\u7684\u7248\u672c\u53f7\u3002\u5982\u679c\u53ea\u60f3\u67e5\u770b\u7279\u5b9a\u5e93\u7684\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip show \u5e93\u540d<\/code>\u547d\u4ee4\uff0c\u66ff\u6362\u201c\u5e93\u540d\u201d\u4e3a\u4f60\u60f3\u67e5\u8be2\u7684\u5e93\u3002<\/p>\n<p><strong>Python\u5e93\u7684\u5b89\u88c5\u4f4d\u7f6e\u5728\u54ea\u91cc\uff1f<\/strong><br \/>Python\u5e93\u901a\u5e38\u5b89\u88c5\u5728Python\u7684site-packages\u76ee\u5f55\u4e0b\u3002\u8981\u627e\u5230\u8fd9\u4e2a\u76ee\u5f55\uff0c\u53ef\u4ee5\u5728Python\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a  <\/p>\n<pre><code class=\"language-python\">import site\nprint(site.getsitepackages())\n<\/code><\/pre>\n<p>\u8fd9\u5c06\u8fd4\u56de\u4e00\u4e2a\u5217\u8868\uff0c\u5305\u542b\u6240\u6709\u5b89\u88c5\u5e93\u7684\u8def\u5f84\u3002\u5bf9\u4e8e\u865a\u62df\u73af\u5883\uff0c\u8def\u5f84\u4f1a\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b\u5e93\u7684\u6587\u6863\u6216\u4f7f\u7528\u8bf4\u660e\uff1f<\/strong><br \/>\u6bcf\u4e2aPython\u5e93\u901a\u5e38\u90fd\u6709\u81ea\u5df1\u7684\u6587\u6863\uff0c\u63d0\u4f9b\u4f7f\u7528\u8bf4\u660e\u548c\u793a\u4f8b\u4ee3\u7801\u3002\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u5e93\u7684\u5b98\u65b9\u7f51\u7ad9\u6216\u5176\u5728GitHub\u4e0a\u7684\u4ed3\u5e93\u6765\u67e5\u770b\u6587\u6863\u3002\u5927\u591a\u6570\u5e93\u5728PyPI\uff08Python Package Index\uff09\u4e0a\u4e5f\u6709\u76f8\u5173\u94fe\u63a5\uff0c\u4f7f\u7528<code>pip show \u5e93\u540d<\/code>\u547d\u4ee4\u53ef\u4ee5\u627e\u5230\u6587\u6863\u94fe\u63a5\u3002\u5728Python\u4e2d\uff0c\u4f7f\u7528<code>help(\u5e93\u540d)<\/code>\u4e5f\u80fd\u83b7\u53d6\u5e93\u7684\u57fa\u672c\u4fe1\u606f\u548c\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u67e5\u770bPython\u5e93\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u4f7f\u7528pip\u5de5\u5177\u3001\u5728Python\u89e3\u91ca\u5668\u4e2d\u4f7f\u7528help()\u51fd\u6570\u3001\u67e5\u770b [&hellip;]","protected":false},"author":3,"featured_media":975770,"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\/975769"}],"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=975769"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/975769\/revisions"}],"predecessor-version":[{"id":975771,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/975769\/revisions\/975771"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/975770"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=975769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=975769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=975769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}