{"id":980376,"date":"2024-12-27T06:53:58","date_gmt":"2024-12-26T22:53:58","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/980376.html"},"modified":"2024-12-27T06:54:00","modified_gmt":"2024-12-26T22:54:00","slug":"python%e5%a6%82%e4%bd%95%e5%8a%a0%e8%bd%bd%e7%a6%bb%e7%ba%bf%e5%8c%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/980376.html","title":{"rendered":"python\u5982\u4f55\u52a0\u8f7d\u79bb\u7ebf\u5305"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24205811\/6a185252-d699-4678-87b9-fa38b8e51444.webp\" alt=\"python\u5982\u4f55\u52a0\u8f7d\u79bb\u7ebf\u5305\" \/><\/p>\n<p><p> <strong>Python\u52a0\u8f7d\u79bb\u7ebf\u5305\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\uff1a\u4f7f\u7528pip\u4e0b\u8f7d\u5e76\u4fdd\u5b58\u5305\u3001\u901a\u8fc7wheel\u6587\u4ef6\u5b89\u88c5\u3001\u624b\u52a8\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b89\u88c5\u3002<\/strong>\u5176\u4e2d\uff0c\u901a\u8fc7wheel\u6587\u4ef6\u5b89\u88c5\u662f\u4e00\u79cd\u975e\u5e38\u9ad8\u6548\u7684\u65b9\u5f0f\uff0c\u56e0\u4e3awheel\u6587\u4ef6\u662f\u4e00\u79cd\u9884\u7f16\u8bd1\u7684\u5305\u683c\u5f0f\uff0c\u5b89\u88c5\u901f\u5ea6\u8f83\u5feb\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u901a\u8fc7wheel\u6587\u4ef6\u6765\u5b89\u88c5Python\u79bb\u7ebf\u5305\u3002<\/p>\n<\/p>\n<p><p>\u8981\u4f7f\u7528wheel\u6587\u4ef6\u5b89\u88c5Python\u79bb\u7ebf\u5305\uff0c\u9996\u5148\u9700\u8981\u5728\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u73af\u5883\u4e2d\u4e0b\u8f7d\u6240\u9700\u7684\u5305\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<code>pip download package_name<\/code>\u6765\u4e0b\u8f7d\u5305\u7684wheel\u6587\u4ef6\uff0c\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u5c06\u8fd9\u4e9b\u6587\u4ef6\u8f6c\u79fb\u5230\u76ee\u6807\u79bb\u7ebf\u73af\u5883\u4e2d\u3002\u7136\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip install package_name.whl<\/code>\u547d\u4ee4\u5728\u79bb\u7ebf\u73af\u5883\u4e2d\u5b89\u88c5\u8fd9\u4e9b\u5305\u3002\u5982\u679c\u6709\u4f9d\u8d56\u5173\u7cfb\uff0c\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u5305\u7684wheel\u6587\u4ef6\u4e5f\u88ab\u4e0b\u8f7d\u5e76\u8f6c\u79fb\u5230\u79bb\u7ebf\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e0b\u8f7d\u548c\u4fdd\u5b58Python\u5305<\/h3>\n<\/p>\n<p><p>\u5728\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u73af\u5883\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u5728\u4e00\u4e2a\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u73af\u5883\u4e2d\u4e0b\u8f7d\u6240\u9700\u7684Python\u5305\u3002\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u6765\u5b8c\u6210\u8fd9\u4e2a\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528pip\u4e0b\u8f7d\u5305<\/h4>\n<\/p>\n<p><p>\u5728\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u8ba1\u7b97\u673a\u4e0a\uff0c\u4f7f\u7528pip\u7684<code>download<\/code>\u547d\u4ee4\u53ef\u4ee5\u5c06\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u3002\u4f8b\u5982\uff0c\u8981\u4e0b\u8f7d<code>requests<\/code>\u5305\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip download requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f1a\u5c06<code>requests<\/code>\u5305\u53ca\u5176\u4f9d\u8d56\u9879\u4e0b\u8f7d\u5230\u5f53\u524d\u76ee\u5f55\u4e2d\u3002\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2a\u76ee\u5f55\u6765\u5b58\u50a8\u4e0b\u8f7d\u7684\u5305\u6587\u4ef6\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip download requests -d \/path\/to\/save<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u8f6c\u79fb\u4e0b\u8f7d\u7684\u5305<\/h4>\n<\/p>\n<p><p>\u5c06\u4e0b\u8f7d\u597d\u7684\u5305\u6587\u4ef6\uff08\u901a\u5e38\u4e3a<code>.whl<\/code>\u683c\u5f0f\uff09\u901a\u8fc7U\u76d8\u3001\u79fb\u52a8\u786c\u76d8\u6216\u5176\u4ed6\u65b9\u5f0f\u8f6c\u79fb\u5230\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u76ee\u6807\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u901a\u8fc7Wheel\u6587\u4ef6\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>Wheel\u6587\u4ef6\u662f\u4e00\u79cd\u6253\u5305\u683c\u5f0f\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5b89\u88c5Python\u5305\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5wheel\u5305<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5728\u76ee\u6807\u73af\u5883\u4e2d\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86<code>wheel<\/code>\u5de5\u5177\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install wheel<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5b89\u88c5\u4e0b\u8f7d\u7684wheel\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u5728\u76ee\u6807\u73af\u5883\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5wheel\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install \/path\/to\/package.whl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6709\u591a\u4e2awheel\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u901a\u914d\u7b26\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install \/path\/to\/*.whl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u624b\u52a8\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u4e00\u4e9b\u7279\u6b8a\u7684\u5305\uff0c\u53ef\u80fd\u6ca1\u6709\u5bf9\u5e94\u7684wheel\u6587\u4ef6\uff0c\u8fd9\u65f6\u53ef\u4ee5\u9009\u62e9\u624b\u52a8\u4e0b\u8f7d\u6e90\u7801\u5305\u5e76\u8fdb\u884c\u89e3\u538b\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h4>1. \u4e0b\u8f7d\u6e90\u7801\u5305<\/h4>\n<\/p>\n<p><p>\u5728\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u73af\u5883\u4e2d\uff0c\u4f7f\u7528pip\u4e0b\u8f7d\u6e90\u7801\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip download --no-binary :all: package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u4e0b\u8f7d\u6e90\u7801\u5305\uff08\u901a\u5e38\u4e3a<code>.tar.gz<\/code>\u6216<code>.zip<\/code>\u683c\u5f0f\uff09\u3002<\/p>\n<\/p>\n<p><h4>2. \u89e3\u538b\u5e76\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u5c06\u6e90\u7801\u5305\u8f6c\u79fb\u5230\u76ee\u6807\u73af\u5883\u4e2d\uff0c\u89e3\u538b\u5e76\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">tar -xzvf package_name.tar.gz<\/p>\n<p>cd package_name<\/p>\n<p>python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u672c\u5730\u955c\u50cf\u6216\u79c1\u6709PyPI\u670d\u52a1\u5668<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u9700\u8981\u5728\u591a\u4e2a\u65e0\u7f51\u7edc\u8fde\u63a5\u7684\u73af\u5883\u4e2d\u5b89\u88c5Python\u5305\uff0c\u53ef\u4ee5\u8003\u8651\u642d\u5efa\u672c\u5730\u955c\u50cf\u6216\u79c1\u6709PyPI\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><h4>1. \u642d\u5efa\u672c\u5730\u955c\u50cf<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5de5\u5177\u5982<code>bandersnatch<\/code>\u6216<code>devpi<\/code>\uff0c\u53ef\u4ee5\u540c\u6b65\u5b98\u65b9PyPI\u4ed3\u5e93\u7684\u4e00\u90e8\u5206\u6216\u5168\u90e8\u5185\u5bb9\u5230\u672c\u5730\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><h4>2. \u914d\u7f6epip\u4f7f\u7528\u672c\u5730\u955c\u50cf<\/h4>\n<\/p>\n<p><p>\u5728\u76ee\u6807\u73af\u5883\u4e2d\uff0c\u914d\u7f6epip\u4f7f\u7528\u672c\u5730\u955c\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install --index-url http:\/\/your-local-mirror\/simple\/ package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u52a0\u8f7d\u79bb\u7ebf\u5305\u5728\u4e00\u4e9b\u7279\u5b9a\u73af\u5883\u4e2d\u662f\u975e\u5e38\u5fc5\u8981\u7684\uff0c\u5c24\u5176\u662f\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u6216\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u5185\u7f51\u73af\u5883\u3002\u901a\u8fc7\u4e0b\u8f7d\u4fdd\u5b58\u5305\u3001\u4f7f\u7528wheel\u6587\u4ef6\u3001\u624b\u52a8\u89e3\u538b\u5b89\u88c5\u6216\u642d\u5efa\u672c\u5730\u955c\u50cf\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u51b3Python\u79bb\u7ebf\u5305\u52a0\u8f7d\u7684\u95ee\u9898\u3002\u5bf9\u4e8e\u4f01\u4e1a\u6216\u56e2\u961f\uff0c\u642d\u5efa\u672c\u5730\u955c\u50cf\u80fd\u591f\u63d0\u9ad8\u5305\u7ba1\u7406\u7684\u6548\u7387\u548c\u5b89\u5168\u6027\uff0c\u662f\u4e00\u79cd\u503c\u5f97\u8003\u8651\u7684\u65b9\u6848\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u79bb\u7ebf\u5305\u8fdb\u884c\u5b89\u88c5\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u4f7f\u7528\u79bb\u7ebf\u5305\u8fdb\u884c\u5b89\u88c5\u901a\u5e38\u6d89\u53ca\u4e0b\u8f7d\u6240\u9700\u7684\u5e93\u7684.whl\u6216.tar.gz\u6587\u4ef6\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95eePyPI\u7f51\u7ad9\u4e0b\u8f7d\u6240\u9700\u7684\u5305\uff0c\u7136\u540e\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u5305\u542b\u8fd9\u4e9b\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u4f7f\u7528\u547d\u4ee4<code>pip install package_name.whl<\/code>\u6216<code>pip install package_name.tar.gz<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u786e\u4fdd\u60a8\u5df2\u5b89\u88c5\u76f8\u5e94\u7684pip\u7248\u672c\uff0c\u4ee5\u907f\u514d\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n<p><strong>\u4f7f\u7528\u79bb\u7ebf\u5305\u65f6\u6709\u54ea\u4e9b\u5e38\u89c1\u9519\u8bef\u53ca\u89e3\u51b3\u65b9\u6cd5\uff1f<\/strong><br \/>\u5728\u4f7f\u7528\u79bb\u7ebf\u5305\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u9519\u8bef\uff0c\u4f8b\u5982\u4f9d\u8d56\u9879\u7f3a\u5931\u6216\u7248\u672c\u4e0d\u517c\u5bb9\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u5efa\u8bae\u5728\u5b89\u88c5\u524d\u67e5\u770b\u5305\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u5e76\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u9879\u7684\u79bb\u7ebf\u5305\u90fd\u5df2\u4e0b\u8f7d\u3002\u5982\u679c\u51fa\u73b0\u201c\u627e\u4e0d\u5230\u6a21\u5757\u201d\u6216\u201c\u7248\u672c\u51b2\u7a81\u201d\u7684\u9519\u8bef\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u9002\u5f53\u7248\u672c\u7684\u4f9d\u8d56\u5305\u6765\u89e3\u51b3\u3002<\/p>\n<p><strong>\u79bb\u7ebf\u5305\u7684\u4f18\u52bf\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u4f7f\u7528\u79bb\u7ebf\u5305\u7684\u4e3b\u8981\u4f18\u52bf\u5728\u4e8e\u53ef\u4ee5\u5728\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u73af\u5883\u4e2d\u8fdb\u884c\u5b89\u88c5\u3002\u8fd9\u5bf9\u4e8e\u5728\u5b89\u5168\u6027\u9ad8\u6216\u7f51\u7edc\u53d7\u9650\u7684\u73af\u5883\u4e2d\u5de5\u4f5c\u975e\u5e38\u6709\u7528\u3002\u6b64\u5916\uff0c\u79bb\u7ebf\u5305\u53ef\u4ee5\u51cf\u5c11\u5b89\u88c5\u65f6\u95f4\uff0c\u56e0\u4e3a\u60a8\u4e0d\u9700\u8981\u5b9e\u65f6\u4e0b\u8f7d\u4f9d\u8d56\u9879\uff0c\u6240\u6709\u6587\u4ef6\u90fd\u5df2\u7ecf\u51c6\u5907\u597d\u3002\u5bf9\u4e8e\u9700\u8981\u5728\u591a\u53f0\u673a\u5668\u4e0a\u8fdb\u884c\u76f8\u540c\u914d\u7f6e\u7684\u9879\u76ee\uff0c\u79bb\u7ebf\u5305\u4e5f\u80fd\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u52a0\u8f7d\u79bb\u7ebf\u5305\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\uff1a\u4f7f\u7528pip\u4e0b\u8f7d\u5e76\u4fdd\u5b58\u5305\u3001\u901a\u8fc7wheel\u6587\u4ef6\u5b89\u88c5\u3001\u624b\u52a8\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b89\u88c5 [&hellip;]","protected":false},"author":3,"featured_media":980383,"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\/980376"}],"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=980376"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/980376\/revisions"}],"predecessor-version":[{"id":980388,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/980376\/revisions\/980388"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/980383"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=980376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=980376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=980376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}