{"id":175313,"date":"2024-05-08T18:48:56","date_gmt":"2024-05-08T10:48:56","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/175313.html"},"modified":"2024-05-08T18:49:01","modified_gmt":"2024-05-08T10:49:01","slug":"python%e6%a8%a1%e5%9d%97%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85-%e5%b9%b6%e7%a1%ae%e8%ae%a4%e6%a8%a1%e5%9d%97%e5%b7%b2%e7%bb%8f%e5%ae%89%e8%a3%85%e5%a5%bd","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/175313.html","title":{"rendered":"Python\u6a21\u5757\u5982\u4f55\u5b89\u88c5 \u5e76\u786e\u8ba4\u6a21\u5757\u5df2\u7ecf\u5b89\u88c5\u597d"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27053220\/6070022e-e346-423b-9ef5-63c7c63b8715.webp\" alt=\"Python\u6a21\u5757\u5982\u4f55\u5b89\u88c5 \u5e76\u786e\u8ba4\u6a21\u5757\u5df2\u7ecf\u5b89\u88c5\u597d\" \/><\/p>\n<p><p>\u5b89\u88c5Python\u6a21\u5757\u4e3b\u8981\u901a\u8fc7\u51e0\u79cd\u65b9\u5f0f\uff1a<strong>\u4f7f\u7528pip\u5b89\u88c5\u3001\u4ece\u6e90\u7801\u5b89\u88c5\u3001\u4f7f\u7528conda\u5b89\u88c5<\/strong>\u3002\u786e\u8ba4\u6a21\u5757\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u5728Python\u89e3\u91ca\u5668\u4e2d\u5c1d\u8bd5\u5bfc\u5165\u8be5\u6a21\u5757\u6216\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u6765\u5b9e\u73b0\u3002\u5728\u8fd9\u4e9b\u65b9\u6cd5\u4e2d\uff0c<strong>\u4f7f\u7528pip\u5b89\u88c5\u662f\u6700\u5e38\u89c1\u4e14\u63a8\u8350\u7684\u65b9\u6cd5<\/strong>\uff0c\u56e0\u4e3a\u5b83\u4e0d\u4ec5\u53ef\u4ee5\u81ea\u52a8\u4e0b\u8f7d\u6a21\u5757\uff0c\u8fd8\u80fd\u7ba1\u7406\u6a21\u5757\u4e4b\u95f4\u7684\u4f9d\u8d56\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528PIP\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>Pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u4f60\u5b89\u88c5\u548c\u7ba1\u7406\u989d\u5916\u7684\u5e93\u548c\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5PIP<\/h4>\n<\/p>\n<p><p>\u5927\u591a\u6570Python\u53d1\u884c\u7248\u5df2\u7ecf\u5305\u542b\u4e86pip\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5pip\u662f\u5426\u5df2\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u7cfb\u7edf\u63d0\u793a\u672a\u627e\u5230pip\u547d\u4ee4\uff0c\u4f60\u9700\u8981\u9996\u5148\u5b89\u88c5\u5b83\u3002Python\u5b98\u7f51\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u5b89\u88c5\u6307\u5357\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528PIP\u5b89\u88c5\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528pip\u5b89\u88c5Python\u6a21\u5757\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c\u4e0b\u5217\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install &lt;\u6a21\u5757\u540d\u79f0&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u8981\u5b89\u88c5\u8457\u540d\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93NumPy\uff0c\u4f60\u53ea\u9700\u8981\u8fd0\u884c<code>pip install numpy<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4ece\u6e90\u7801\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u67d0\u4e2a\u6a21\u5757\u5728pip\u4e2d\u4e0d\u53ef\u7528\u6216\u4f60\u9700\u8981\u5b89\u88c5\u6a21\u5757\u7684\u7279\u5b9a\u7248\u672c\uff0c\u4ece\u6e90\u7801\u5b89\u88c5\u662f\u4e00\u4e2a\u53ef\u9009\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h4>1. \u4e0b\u8f7d\u6e90\u7801<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u4ece\u6a21\u5757\u7684\u5b98\u65b9\u7f51\u7ad9\u6216Github\u9875\u9762\u4e0b\u8f7d\u6e90\u7801\u5305\u3002<\/p>\n<\/p>\n<p><h4>2. \u5b89\u88c5\u6e90\u7801<\/h4>\n<\/p>\n<p><p>\u4e0b\u8f7d\u540e\uff0c\u89e3\u538b\u7f29\u5305\u5e76\u901a\u8fc7\u547d\u4ee4\u884c\u8fdb\u5165\u8be5\u76ee\u5f55\u3002\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f1a\u7f16\u8bd1\u6a21\u5757\u5e76\u5b89\u88c5\u5230Python\u7684site-packages\u76ee\u5f55\u4e0b\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528CONDA\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>Conda\u662f\u53e6\u4e00\u4e2a\u6d41\u884c\u7684\u5305\u7ba1\u7406\u7cfb\u7edf\uff0c\u7528\u4e8e\u5b89\u88c5\u3001\u8fd0\u884c\u548c\u66f4\u65b0\u5305\u548c\u5b83\u4eec\u7684\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Anaconda\u6216Miniconda<\/h4>\n<\/p>\n<p><p>\u8981\u4f7f\u7528conda\uff0c\u4f60\u9700\u8981\u5b89\u88c5Anaconda\u6216Miniconda\u3002Anaconda\u662f\u5305\u542b\u4e86conda\u3001Python\u53ca\u8bb8\u591a\u5e38\u89c1\u5305\u7684\u79d1\u5b66\u8ba1\u7b97\u53d1\u884c\u7248\uff0c\u800cMiniconda\u5219\u66f4\u52a0\u8f7b\u91cf\u7ea7\uff0c\u53ea\u5305\u542bconda\u548c\u5fc5\u8981\u7684Python\u5305\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528CONDA\u5b89\u88c5\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7Conda\u5b89\u88c5\u6a21\u5757\u7684\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install &lt;\u6a21\u5757\u540d\u79f0&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5b89\u88c5NumPy\u7684\u547d\u4ee4\u662f<code>conda install numpy<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u786e\u8ba4\u6a21\u5757\u5df2\u7ecf\u5b89\u88c5\u597d<\/h3>\n<\/p>\n<p><p>\u786e\u8ba4Python\u6a21\u5757\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u5c1d\u8bd5\u5bfc\u5165\u8be5\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528Python\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u8f93\u5165<code>python<\/code>\u8fdb\u5165Python\u89e3\u91ca\u5668\uff0c\u7136\u540e\u5c1d\u8bd5\u5bfc\u5165\u76ee\u6807\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import &lt;\u6a21\u5757\u540d\u79f0&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6ca1\u6709\u9519\u8bef\u4fe1\u606f\u8fd4\u56de\uff0c\u8868\u793a\u6a21\u5757\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528PIP LIST\u547d\u4ee4<\/h4>\n<\/p>\n<p><p>\u53e6\u4e00\u4e2a\u786e\u8ba4\u65b9\u5f0f\u662f\u7528<code>pip list<\/code>\u547d\u4ee4\u5217\u51fa\u5df2\u5b89\u88c5\u7684\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u4f1a\u663e\u793a\u51fa\u6240\u6709\u5df2\u5b89\u88c5\u7684Python\u5305\u53ca\u5176\u7248\u672c\u53f7\uff0c\u4f60\u53ef\u4ee5\u5728\u5217\u8868\u4e2d\u67e5\u627e\u76ee\u6807\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><p>\u603b\u4e4b\uff0c\u5b89\u88c5Python\u6a21\u5757\u7684\u8fc7\u7a0b\u7b80\u5355\u4e14\u591a\u6837\uff0c\u4e0d\u540c\u7684\u5b89\u88c5\u65b9\u5f0f\u9002\u5e94\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u3002\u65e0\u8bba\u662f\u901a\u8fc7pip\u3001\u4ece\u6e90\u7801\u8fd8\u662f\u4f7f\u7528conda\u5b89\u88c5\uff0c\u6700\u91cd\u8981\u7684\u662f\u786e\u8ba4\u6a21\u5757\u5df2\u6b63\u786e\u5b89\u88c5\u4e14\u53ef\u5728\u9879\u76ee\u4e2d\u4f7f\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5728Python\u4e2d\u5b89\u88c5\u6a21\u5757\uff1f<\/strong><\/p>\n<ul>\n<li>\u901a\u8fc7\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5\u6a21\u5757\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>pip install \u6a21\u5757\u540d\u79f0<\/code>\uff0cpip\u4f1a\u81ea\u52a8\u4ecePython\u8f6f\u4ef6\u5305\u7d22\u5f15\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6240\u9700\u7684\u6a21\u5757\u3002<\/li>\n<li>\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u624b\u52a8\u4e0b\u8f7d\u6a21\u5757\u6e90\u4ee3\u7801\uff0c\u5e76\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u5165\u6e90\u4ee3\u7801\u6240\u5728\u7684\u6587\u4ef6\u5939\u3002\u7136\u540e\u8fd0\u884c<code>python setup.py install<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u6a21\u5757\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5982\u4f55\u786e\u8ba4\u6a21\u5757\u662f\u5426\u5df2\u6210\u529f\u5b89\u88c5\uff1f<\/strong><\/p>\n<ul>\n<li>\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>pip show \u6a21\u5757\u540d\u79f0<\/code>\u547d\u4ee4\u6765\u67e5\u770b\u5df2\u5b89\u88c5\u6a21\u5757\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7248\u672c\u53f7\u548c\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<li>\u5982\u679c\u60f3\u5728Python\u811a\u672c\u4e2d\u786e\u8ba4\u6a21\u5757\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528<code>import \u6a21\u5757\u540d\u79f0<\/code>\u8bed\u53e5\u6765\u5c1d\u8bd5\u5bfc\u5165\u6a21\u5757\u3002\u5982\u679c\u6ca1\u6709\u62a5\u9519\uff0c\u5219\u8bf4\u660e\u6a21\u5757\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u9519\u8bef\u8be5\u5982\u4f55\u5904\u7406\uff1f<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u9519\u8bef\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\u6765\u89e3\u51b3\u95ee\u9898\uff1a\n<ul>\n<li>\u786e\u4fdd\u4f7f\u7528\u7684pip\u547d\u4ee4\u4e0e\u5f53\u524dPython\u7248\u672c\u5bf9\u5e94\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip --version<\/code>\u547d\u4ee4\u6765\u68c0\u67e5pip\u7684\u7248\u672c\u3002<\/li>\n<li>\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u662f\u5426\u6b63\u5e38\uff0c\u6709\u65f6\u4e0b\u8f7d\u6a21\u5757\u65f6\u53ef\u80fd\u4f1a\u7531\u4e8e\u7f51\u7edc\u95ee\u9898\u5bfc\u81f4\u5931\u8d25\u3002<\/li>\n<li>\u786e\u8ba4\u6a21\u5757\u7684\u540d\u79f0\u62fc\u5199\u662f\u5426\u6b63\u786e\u3002<\/li>\n<li>\u5982\u679c\u6b63\u5728\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u8bf7\u786e\u4fdd\u5df2\u7ecf\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0c\u5e76\u4e14\u5728\u6b63\u786e\u7684\u73af\u5883\u4e2d\u5b89\u88c5\u6a21\u5757\u3002<\/li>\n<li>\u5982\u679c\u4ee5\u4e0a\u65b9\u6cd5\u90fd\u6ca1\u6709\u89e3\u51b3\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5728Python\u5b98\u65b9\u7f51\u7ad9\u6216\u6a21\u5757\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0a\u67e5\u627e\u66f4\u591a\u5173\u4e8e\u5b89\u88c5\u548c\u914d\u7f6e\u6a21\u5757\u7684\u4fe1\u606f\uff0c\u6216\u8005\u5bfb\u6c42\u76f8\u5173\u8bba\u575b\u6216\u793e\u533a\u7684\u5e2e\u52a9\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u5b89\u88c5Python\u6a21\u5757\u4e3b\u8981\u901a\u8fc7\u51e0\u79cd\u65b9\u5f0f\uff1a\u4f7f\u7528pip\u5b89\u88c5\u3001\u4ece\u6e90\u7801\u5b89\u88c5\u3001\u4f7f\u7528conda\u5b89\u88c5\u3002\u786e\u8ba4\u6a21\u5757\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\uff0c\u5219 [&hellip;]","protected":false},"author":3,"featured_media":175320,"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\/175313"}],"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=175313"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/175313\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/175320"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=175313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=175313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=175313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}