{"id":993370,"date":"2024-12-27T08:45:27","date_gmt":"2024-12-27T00:45:27","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/993370.html"},"modified":"2024-12-27T08:45:29","modified_gmt":"2024-12-27T00:45:29","slug":"%e5%a6%82%e4%bd%95%e7%a6%bb%e7%ba%bf%e5%ae%89%e8%a3%85python%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/993370.html","title":{"rendered":"\u5982\u4f55\u79bb\u7ebf\u5b89\u88c5python\u6a21\u5757"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25070807\/e229b821-b3c9-4521-94f0-827483c060e2.webp\" alt=\"\u5982\u4f55\u79bb\u7ebf\u5b89\u88c5python\u6a21\u5757\" \/><\/p>\n<p><p> <strong>\u79bb\u7ebf\u5b89\u88c5Python\u6a21\u5757\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u4e0b\u8f7d\u6a21\u5757\u7684\u6e90\u7801\u5305\u3001\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\u3001\u89e3\u51b3\u4f9d\u8d56\u95ee\u9898\u3001\u4f7f\u7528\u8f6e\u5b50\u6587\u4ef6\uff08Wheel\uff09\u8fdb\u884c\u5b89\u88c5\u3002<\/strong>\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u5c55\u5f00\u5176\u4e2d\u7684\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5373\u4f7f\u7528\u8f6e\u5b50\u6587\u4ef6\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u79bb\u7ebf\u5b89\u88c5Python\u6a21\u5757\u662f\u56e0\u4e3a\u5728\u76ee\u6807\u673a\u5668\u4e0a\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u4e92\u8054\u7f51\u3002\u4e3a\u4e86\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5b89\u88c5\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u7684\u5305\u7ba1\u7406\u5de5\u5177pip\uff0c\u7ed3\u5408\u4e8b\u5148\u4e0b\u8f7d\u597d\u7684\u6a21\u5757\u6587\u4ef6\uff0c\u6765\u5b8c\u6210\u79bb\u7ebf\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e0b\u8f7d\u6a21\u5757\u7684\u6e90\u7801\u5305<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5728\u8054\u7f51\u73af\u5883\u4e2d\u4e0b\u8f7d\u6a21\u5757<\/strong><br \/>\u9996\u5148\uff0c\u9700\u8981\u5728\u4e00\u53f0\u53ef\u4ee5\u8054\u7f51\u7684\u8ba1\u7b97\u673a\u4e0a\u4e0b\u8f7d\u9700\u8981\u5b89\u88c5\u7684Python\u6a21\u5757\u3002\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u8fdb\u884c\u4e0b\u8f7d\uff0c\u4f46\u4e0d\u5b89\u88c5\u3002\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code>pip download &lt;module_name&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u4f1a\u4e0b\u8f7d\u6307\u5b9a\u6a21\u5757\u7684\u8f6e\u5b50\u6587\u4ef6\uff08.whl\uff09\u6216\u6e90\u7801\u5305\uff08.tar.gz, .zip\u7b49\uff09\uff0c\u5e76\u4fdd\u5b58\u5728\u5f53\u524d\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u786e\u8ba4\u4e0b\u8f7d\u7684\u6587\u4ef6<\/strong><br \/>\u68c0\u67e5\u4e0b\u8f7d\u7684\u6587\u4ef6\uff0c\u786e\u4fdd\u4e0b\u8f7d\u7684\u662f\u6240\u9700\u6a21\u5757\u7684\u6700\u65b0\u7248\u672c\u6216\u6307\u5b9a\u7248\u672c\u3002\u901a\u5e38\uff0c.whl\u6587\u4ef6\u662f\u9996\u9009\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f\u9884\u7f16\u8bd1\u7684\uff0c\u5b89\u88c5\u901f\u5ea6\u66f4\u5feb\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8f6c\u79fb\u6587\u4ef6\u5230\u76ee\u6807\u673a\u5668<\/strong><br \/>\u5c06\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\u901a\u8fc7U\u76d8\u6216\u5176\u4ed6\u65b9\u5f0f\u8f6c\u79fb\u5230\u76ee\u6807\u673a\u5668\u4e0a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pip\u5b89\u88c5<\/strong><br \/>\u5728\u76ee\u6807\u673a\u5668\u4e0a\uff0c\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\u4e0b\u8f7d\u7684\u6a21\u5757\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install &lt;module_name&gt;.whl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4e0b\u8f7d\u7684\u662f\u6e90\u7801\u5305\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install &lt;module_name&gt;.tar.gz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u89e3\u51b3\u4f9d\u8d56\u95ee\u9898<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u63d0\u524d\u4e0b\u8f7d\u4f9d\u8d56\u5305<\/strong><br \/>\u5728\u4e0b\u8f7d\u6a21\u5757\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u63d0\u524d\u4e0b\u8f7d\u5b83\u7684\u4f9d\u8d56\u5305\u3002\u53ef\u4ee5\u4f7f\u7528pip\u7684<code>--no-deps<\/code>\u53c2\u6570\u6765\u67e5\u770b\u4f9d\u8d56\u5173\u7cfb\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install &lt;module_name&gt; --no-deps<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u5355\u72ec\u4e0b\u8f7d\u8fd9\u4e9b\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56\u5305<\/strong><br \/>\u6309\u7167\u4e0e\u4e3b\u6a21\u5757\u76f8\u540c\u7684\u6b65\u9aa4\uff0c\u9010\u4e2a\u5b89\u88c5\u4f9d\u8d56\u5305\uff0c\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u5173\u7cfb\u90fd\u5f97\u5230\u6ee1\u8db3\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u4f7f\u7528\u8f6e\u5b50\u6587\u4ef6\uff08Wheel\uff09\u8fdb\u884c\u5b89\u88c5<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e86\u89e3\u8f6e\u5b50\u6587\u4ef6<\/strong><br \/>\u8f6e\u5b50\u6587\u4ef6\u662fPython\u7684\u4e00\u79cd\u6253\u5305\u683c\u5f0f\uff0c\u6269\u5c55\u540d\u4e3a.whl\uff0c\u5b83\u662f\u4e00\u79cd\u6807\u51c6\u7684Python\u8f6f\u4ef6\u5305\u683c\u5f0f\u3002\u4e0e\u6e90\u7801\u5305\u76f8\u6bd4\uff0c.whl\u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u7f16\u8bd1\u540e\u7684\u4ee3\u7801\uff0c\u56e0\u6b64\u5b89\u88c5\u901f\u5ea6\u66f4\u5feb\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4ecePyPI\u4e0b\u8f7d\u8f6e\u5b50\u6587\u4ef6<\/strong><br \/>\u53ef\u4ee5\u5728PyPI\uff08Python Package Index\uff09\u4e0a\u627e\u5230\u6a21\u5757\u7684.whl\u6587\u4ef6\u3002\u4e0b\u8f7d\u65f6\uff0c\u786e\u4fdd\u9009\u62e9\u4e0e\u76ee\u6807\u673a\u5668Python\u7248\u672c\u548c\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5339\u914d\u7684.whl\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pip\u5b89\u88c5\u8f6e\u5b50\u6587\u4ef6<\/strong><br \/>\u5728\u76ee\u6807\u673a\u5668\u4e0a\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\u8f6e\u5b50\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install &lt;module_name&gt;-&lt;version&gt;-py&lt;python_version&gt;-none-any.whl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u672c\u5730\u5305\u76ee\u5f55<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u672c\u5730\u5305\u76ee\u5f55<\/strong><br \/>\u5728\u8054\u7f51\u7684\u8ba1\u7b97\u673a\u4e0a\uff0c\u4f7f\u7528pip\u4e0b\u8f7d\u6240\u6709\u9700\u8981\u7684\u5305\u53ca\u5176\u4f9d\u8d56\u5230\u4e00\u4e2a\u6307\u5b9a\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code>pip download -d \/path\/to\/local\/dir &lt;module_name&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728\u76ee\u6807\u673a\u5668\u4e0a\u5b89\u88c5<\/strong><br \/>\u5728\u76ee\u6807\u673a\u5668\u4e0a\uff0c\u901a\u8fc7\u6307\u5b9a\u672c\u5730\u5305\u76ee\u5f55\u6765\u5b89\u88c5\u6a21\u5757\u53ca\u5176\u4f9d\u8d56\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install --no-index --find-links=\/path\/to\/local\/dir &lt;module_name&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u603b\u7ed3\u4e0e\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<ul>\n<li>\n<p><strong>\u786e\u4fddPython\u7248\u672c\u517c\u5bb9\u6027<\/strong><br \/>\u5728\u4e0b\u8f7d\u548c\u5b89\u88c5\u6a21\u5757\u65f6\uff0c\u786e\u4fdd\u6a21\u5757\u4e0e\u76ee\u6807\u673a\u5668\u4e0a\u7684Python\u7248\u672c\u517c\u5bb9\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5904\u7406\u672c\u5730\u7f16\u8bd1\u9700\u6c42<\/strong><br \/>\u67d0\u4e9b\u6a21\u5757\u53ef\u80fd\u9700\u8981\u672c\u5730\u7f16\u8bd1\u5de5\u5177\uff08\u5982C\u7f16\u8bd1\u5668\uff09\uff0c\u7279\u522b\u662f\u5728\u5b89\u88c5\u6e90\u7801\u5305\u65f6\u3002\u786e\u4fdd\u76ee\u6807\u673a\u5668\u4e0a\u5b89\u88c5\u4e86\u5fc5\u8981\u7684\u7f16\u8bd1\u5de5\u5177\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u865a\u62df\u73af\u5883<\/strong><br \/>\u4e3a\u4e86\u907f\u514d\u5f71\u54cd\u7cfb\u7edfPython\u73af\u5883\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u5b89\u88c5\u548c\u7ba1\u7406Python\u6a21\u5757\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5728\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u73af\u5883\u4e2d\u6210\u529f\u5b89\u88c5Python\u6a21\u5757\u3002\u8fd9\u79cd\u65b9\u6cd5\u5728\u9700\u8981\u4e25\u683c\u63a7\u5236\u73af\u5883\u6216\u65e0\u6cd5\u8054\u7f51\u7684\u60c5\u51b5\u4e0b\u5c24\u5176\u6709\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u6ca1\u6709\u4e92\u8054\u7f51\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\u5b89\u88c5Python\u6a21\u5757\uff1f<\/strong><br \/>\u5728\u6ca1\u6709\u7f51\u7edc\u7684\u73af\u5883\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u9884\u5148\u4e0b\u8f7d\u6240\u9700\u7684Python\u6a21\u5757\u53ca\u5176\u4f9d\u8d56\u9879\u8fdb\u884c\u79bb\u7ebf\u5b89\u88c5\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u4e00\u4e2a\u6709\u4e92\u8054\u7f51\u8fde\u63a5\u7684\u8ba1\u7b97\u673a\u4e0a\u4f7f\u7528<code>pip download<\/code>\u547d\u4ee4\u4e0b\u8f7d\u76f8\u5173\u6a21\u5757\u53ca\u5176\u4f9d\u8d56\uff0c\u751f\u6210\u4e00\u4e2a\u5305\u542b\u6240\u6709\u5fc5\u8981\u6587\u4ef6\u7684\u6587\u4ef6\u5939\u3002\u4e4b\u540e\uff0c\u5c06\u8be5\u6587\u4ef6\u5939\u8f6c\u79fb\u5230\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\uff0c\u5e76\u4f7f\u7528<code>pip install --no-index --find-links=\u8def\u5f84<\/code>\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u79bb\u7ebf\u5b89\u88c5Python\u6a21\u5757\u9700\u8981\u54ea\u4e9b\u51c6\u5907\u5de5\u4f5c\uff1f<\/strong><br \/>\u4e3a\u4e86\u786e\u4fdd\u987a\u5229\u8fdb\u884c\u79bb\u7ebf\u5b89\u88c5\uff0c\u60a8\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u5185\u5bb9\uff1a\u6709\u7f51\u7edc\u7684\u8ba1\u7b97\u673a\uff0cPython\u73af\u5883\u5df2\u7ecf\u5b89\u88c5\u7684\u76ee\u6807\u8ba1\u7b97\u673a\uff0c\u4ee5\u53ca\u547d\u4ee4\u884c\u5de5\u5177\u3002\u5728\u6709\u7f51\u7edc\u7684\u8ba1\u7b97\u673a\u4e0a\uff0c\u4f7f\u7528<code>pip download<\/code>\u547d\u4ee4\u4e0b\u8f7d\u6240\u9700\u6a21\u5757\uff0c\u5e76\u786e\u4fdd\u5c06\u6240\u6709\u76f8\u5173\u4f9d\u8d56\u9879\u4e5f\u4e00\u5e76\u4e0b\u8f7d\u3002\u51c6\u5907\u597d\u540e\uff0c\u53ef\u4ee5\u5c06\u4e0b\u8f7d\u7684\u6587\u4ef6\u5939\u901a\u8fc7USB\u6216\u5176\u4ed6\u65b9\u5f0f\u8f6c\u79fb\u5230\u76ee\u6807\u8ba1\u7b97\u673a\u3002<\/p>\n<p><strong>\u5982\u679c\u79bb\u7ebf\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u4f9d\u8d56\u51b2\u7a81\uff0c\u5e94\u8be5\u600e\u4e48\u529e\uff1f<\/strong><br \/>\u5728\u79bb\u7ebf\u5b89\u88c5Python\u6a21\u5757\u65f6\uff0c\u4f9d\u8d56\u51b2\u7a81\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u4e00\u95ee\u9898\uff0c\u5efa\u8bae\u5728\u6709\u7f51\u7edc\u7684\u8ba1\u7b97\u673a\u4e0a\u4f7f\u7528<code>pip download<\/code>\u547d\u4ee4\u65f6\uff0c\u786e\u4fdd\u4e0b\u8f7d\u7684\u6a21\u5757\u53ca\u5176\u7248\u672c\u4e0e\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u5df2\u5b89\u88c5\u7684\u6a21\u5757\u7248\u672c\u517c\u5bb9\u3002\u5982\u679c\u5df2\u7ecf\u53d1\u751f\u51b2\u7a81\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<code>pip check<\/code>\u547d\u4ee4\u68c0\u67e5\u4f9d\u8d56\u5173\u7cfb\uff0c\u5e76\u624b\u52a8\u8c03\u6574\u4e0b\u8f7d\u7684\u6a21\u5757\u7248\u672c\u4ee5\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u79bb\u7ebf\u5b89\u88c5Python\u6a21\u5757\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u4e0b\u8f7d\u6a21\u5757\u7684\u6e90\u7801\u5305\u3001\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\u3001\u89e3\u51b3\u4f9d\u8d56\u95ee\u9898\u3001\u4f7f\u7528\u8f6e\u5b50\u6587\u4ef6\uff08Whee [&hellip;]","protected":false},"author":3,"featured_media":993373,"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\/993370"}],"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=993370"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/993370\/revisions"}],"predecessor-version":[{"id":993378,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/993370\/revisions\/993378"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/993373"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=993370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=993370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=993370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}