{"id":954163,"date":"2024-12-27T01:52:28","date_gmt":"2024-12-26T17:52:28","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/954163.html"},"modified":"2024-12-27T01:52:30","modified_gmt":"2024-12-26T17:52:30","slug":"python%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85zip%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/954163.html","title":{"rendered":"python\u5982\u4f55\u5b89\u88c5zip\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25094436\/47221988-da6f-4277-ba35-95aa96ee46af.webp\" alt=\"python\u5982\u4f55\u5b89\u88c5zip\u6587\u4ef6\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5b89\u88c5zip\u6587\u4ef6\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a\u76f4\u63a5\u89e3\u538b\u5b89\u88c5\u3001\u4f7f\u7528pip\u5de5\u5177\u5b89\u88c5\u3001\u4f7f\u7528setuptools\u6a21\u5757\u8fdb\u884c\u5b89\u88c5<\/strong>\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\u6765\u8bf4\uff0c\u4f7f\u7528pip\u5de5\u5177\u662f\u6700\u65b9\u4fbf\u548c\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u4e0b\u9762\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e09\u79cd\u65b9\u6cd5\u7684\u6b65\u9aa4\u548c\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u76f4\u63a5\u89e3\u538b\u5b89\u88c5<\/p>\n<\/p>\n<p><p>\u76f4\u63a5\u89e3\u538b\u5b89\u88c5\u662f\u4e00\u79cd\u7b80\u5355\u800c\u76f4\u89c2\u7684\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u4e0d\u9700\u8981\u590d\u6742\u4f9d\u8d56\u5173\u7cfb\u7684Python\u5305\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u89e3\u538b\u7f29zip\u6587\u4ef6<\/strong><br \/>\u9996\u5148\uff0c\u5c06zip\u6587\u4ef6\u89e3\u538b\u5230\u4e00\u4e2a\u4e34\u65f6\u76ee\u5f55\u4e2d\u3002\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u89e3\u538b\u7f29\u5de5\u5177\uff0c\u5982WinRAR\u30017-Zip\u6216\u7cfb\u7edf\u81ea\u5e26\u7684\u89e3\u538b\u5de5\u5177\u3002\u89e3\u538b\u540e\uff0c\u8fdb\u5165\u8be5\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Python\u5b89\u88c5<\/strong><br \/>\u5728\u89e3\u538b\u540e\u7684\u76ee\u5f55\u4e2d\uff0c\u901a\u5e38\u4f1a\u6709\u4e00\u4e2asetup.py\u6587\u4ef6\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows\uff09\u6216\u7ec8\u7aef\uff08Mac\/Linux\uff09\uff0c\u5bfc\u822a\u5230\u89e3\u538b\u540e\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\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\u5c06\u4f1a\u8c03\u7528Python\u7684\u5b89\u88c5\u811a\u672c\uff0c\u5c06\u5305\u5b89\u88c5\u5230Python\u7684site-packages\u76ee\u5f55\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong>\uff1a  <\/p>\n<\/p>\n<ul>\n<li>\u5728\u8fd0\u884c\u4ee5\u4e0a\u547d\u4ee4\u65f6\uff0c\u786e\u4fdd\u4f60\u7684\u547d\u4ee4\u63d0\u793a\u7b26\/\u7ec8\u7aef\u6b63\u5728\u89e3\u538b\u540e\u7684\u76ee\u5f55\u4e2d\u3002<\/li>\n<li>\u6709\u4e9b\u5305\u53ef\u80fd\u6709\u4f9d\u8d56\u9879\uff0c\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4f1a\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u9879\uff0c\u4f60\u9700\u8981\u624b\u52a8\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u9879\u3002<\/li>\n<\/ul>\n<p><p>\u4e8c\u3001\u4f7f\u7528pip\u5de5\u5177\u5b89\u88c5<\/p>\n<\/p>\n<p><p>pip\u662fPython\u5b98\u65b9\u63a8\u8350\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u652f\u6301\u4ecezip\u6587\u4ef6\u4e2d\u5b89\u88c5\u5305\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528pip\u5b89\u88c5zip\u6587\u4ef6<\/strong><br \/>\u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528pip\u5b89\u88c5\u672c\u5730\u7684zip\u6587\u4ef6\u3002\u5728\u547d\u4ee4\u63d0\u793a\u7b26\/\u7ec8\u7aef\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-bash\">pip install path\/to\/yourfile.zip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u5c06<code>path\/to\/yourfile.zip<\/code>\u66ff\u6362\u4e3a\u4f60\u7684zip\u6587\u4ef6\u7684\u5b9e\u9645\u8def\u5f84\u3002<\/li>\n<\/p>\n<\/ol>\n<p><p><strong>\u4f18\u70b9<\/strong>\uff1a  <\/p>\n<\/p>\n<ul>\n<li><strong>\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u9879<\/strong>\uff1apip\u4f1a\u81ea\u52a8\u89e3\u6790\u5e76\u5b89\u88c5\u5305\u7684\u4f9d\u8d56\u9879\u3002<\/li>\n<li><strong>\u65b9\u4fbf\u5feb\u6377<\/strong>\uff1a\u4e0d\u9700\u8981\u624b\u52a8\u89e3\u538b\uff0c\u53ea\u9700\u6307\u5b9azip\u6587\u4ef6\u8def\u5f84\u3002<\/li>\n<\/ul>\n<p><p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong>\uff1a  <\/p>\n<\/p>\n<ul>\n<li>\u786e\u4fdd\u4f60\u7684pip\u7248\u672c\u662f\u6700\u65b0\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pip install --upgrade pip<\/code>\u6765\u66f4\u65b0\u3002<\/li>\n<li>\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528<code>pip3<\/code>\u800c\u4e0d\u662f<code>pip<\/code>\uff0c\u4ee5\u786e\u4fdd\u5b89\u88c5\u5230Python 3\u7684\u73af\u5883\u4e2d\u3002<\/li>\n<\/ul>\n<p><p>\u4e09\u3001\u4f7f\u7528setuptools\u6a21\u5757\u8fdb\u884c\u5b89\u88c5<\/p>\n<\/p>\n<p><p>setuptools\u662fPython\u7684\u4e00\u4e2a\u589e\u5f3a\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u7075\u6d3b\u6027\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5setuptools<\/strong><br \/>\u5982\u679c\u8fd8\u6ca1\u6709\u5b89\u88c5setuptools\uff0c\u53ef\u4ee5\u901a\u8fc7pip\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install setuptools<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u538b\u548c\u5b89\u88c5<\/strong><br \/>\u548c\u76f4\u63a5\u89e3\u538b\u5b89\u88c5\u7c7b\u4f3c\uff0c\u9996\u5148\u89e3\u538bzip\u6587\u4ef6\u3002\u7136\u540e\uff0c\u5728\u89e3\u538b\u540e\u7684\u76ee\u5f55\u4e2d\uff0c\u8fd0\u884c\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>setuptool\u4f1a\u81ea\u52a8\u5904\u7406\u4e00\u4e9b\u590d\u6742\u7684\u4f9d\u8d56\u5173\u7cfb\u548c\u5b89\u88c5\u9009\u9879\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong>\uff1a  <\/p>\n<\/p>\n<ul>\n<li>setuptools\u901a\u5e38\u662fpip\u7684\u540e\u5907\u9009\u9879\uff0c\u5982\u679cpip\u65e0\u6cd5\u5904\u7406\u67d0\u4e9b\u590d\u6742\u7684\u5305\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528setuptools\u3002<\/li>\n<li>\u786e\u4fdd\u89e3\u538b\u540e\u7684\u76ee\u5f55\u7ed3\u6784\u6ca1\u6709\u88ab\u7834\u574f\uff0c\u5c24\u5176\u662f\u5305\u542bsetup.py\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p><p>\u56db\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong><br \/>\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u5b89\u88c5\u5305\u5230\u7cfb\u7edf\u76ee\u5f55\u53ef\u80fd\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u524d\u52a0\u4e0a<code>sudo<\/code>\uff08Linux\/Mac\uff09\u6216\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows\uff09\u6765\u89e3\u51b3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u5173\u7cfb\u95ee\u9898<\/strong><br \/>\u5982\u679c\u9047\u5230\u4f9d\u8d56\u5173\u7cfb\u95ee\u9898\uff0c\u901a\u5e38pip\u4f1a\u7ed9\u51fa\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u3002\u6839\u636e\u9519\u8bef\u63d0\u793a\uff0c\u624b\u52a8\u5b89\u88c5\u7f3a\u5931\u7684\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8def\u5f84\u95ee\u9898<\/strong><br \/>\u786e\u4fdd\u547d\u4ee4\u4e2d\u6307\u5b9a\u7684\u8def\u5f84\u662f\u6b63\u786e\u7684\uff0c\u5c24\u5176\u662f\u5728\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u65f6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f51\u7edc\u95ee\u9898<\/strong><br \/>\u4f7f\u7528pip\u5b89\u88c5\u65f6\uff0c\u5982\u679c\u9700\u8981\u4e0b\u8f7d\u4f9d\u8d56\u9879\uff0c\u53ef\u80fd\u4f1a\u56e0\u4e3a\u7f51\u7edc\u95ee\u9898\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25\u3002\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6362\u7f51\u7edc\u73af\u5883\u6216\u4f7f\u7528\u79bb\u7ebf\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u5b89\u88c5zip\u6587\u4ef6\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\uff0c\u6839\u636e\u4f60\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\uff0c<strong>\u4f7f\u7528pip\u5de5\u5177\u662f\u6700\u65b9\u4fbf\u548c\u63a8\u8350\u7684\u65b9\u5f0f<\/strong>\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u5e76\u4e14\u64cd\u4f5c\u7b80\u5355\u3002\u5bf9\u4e8e\u66f4\u9ad8\u7ea7\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u9009\u62e9\u76f4\u63a5\u89e3\u538b\u5b89\u88c5\u6216\u4f7f\u7528setuptools\u3002\u65e0\u8bba\u54ea\u79cd\u65b9\u6cd5\uff0c\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u914d\u7f6e\u6b63\u786e\uff0c\u59cb\u7ec8\u662f\u5b89\u88c5\u6210\u529f\u7684\u5173\u952e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b89\u88c5\u6765\u81eazip\u6587\u4ef6\u7684\u5e93\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u5b89\u88c5\u6765\u81eazip\u6587\u4ef6\u7684\u5e93\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u5de5\u5177\u3002\u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>pip install path\/to\/yourfile.zip<\/code>\u3002\u786e\u4fdd\u5c06<code>path\/to\/yourfile.zip<\/code>\u66ff\u6362\u4e3azip\u6587\u4ef6\u7684\u5b9e\u9645\u8def\u5f84\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u672c\u5730\u5b58\u50a8\u7684zip\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5b89\u88c5zip\u6587\u4ef6\u4e2d\u4f9d\u8d56\u7684\u5e93\u65f6\u9700\u8981\u6ce8\u610f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728\u5b89\u88c5zip\u6587\u4ef6\u4e2d\u7684\u5e93\u65f6\uff0c\u786e\u4fddzip\u6587\u4ef6\u5185\u7684\u7ed3\u6784\u6b63\u786e\uff0c\u5e76\u5305\u542b<code>setup.py<\/code>\u6587\u4ef6\u3002\u6b64\u6587\u4ef6\u5b9a\u4e49\u4e86\u5305\u7684\u5b89\u88c5\u4fe1\u606f\u548c\u4f9d\u8d56\u5173\u7cfb\u3002\u6b64\u5916\uff0c\u68c0\u67e5zip\u6587\u4ef6\u662f\u5426\u5305\u542b\u6240\u9700\u7684\u6240\u6709\u4f9d\u8d56\u5e93\uff0c\u4ee5\u907f\u514d\u5728\u8fd0\u884c\u65f6\u51fa\u73b0\u95ee\u9898\u3002<\/p>\n<p><strong>\u5982\u4f55\u68c0\u67e5zip\u6587\u4ef6\u4e2d\u7684Python\u5305\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u5728Python\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>import package_name<\/code>\u6765\u68c0\u67e5\u5305\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u66ff\u6362<code>package_name<\/code>\u4e3a\u4f60\u8981\u68c0\u67e5\u7684\u5e93\u540d\u3002\u5982\u679c\u6ca1\u6709\u9519\u8bef\u6d88\u606f\uff0c\u5219\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u6240\u6709\u5e93\u53ca\u5176\u7248\u672c\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5b89\u88c5zip\u6587\u4ef6\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a\u76f4\u63a5\u89e3\u538b\u5b89\u88c5\u3001\u4f7f\u7528pip\u5de5\u5177\u5b89\u88c5\u3001\u4f7f\u7528setuptools [&hellip;]","protected":false},"author":3,"featured_media":954164,"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\/954163"}],"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=954163"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/954163\/revisions"}],"predecessor-version":[{"id":954165,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/954163\/revisions\/954165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/954164"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=954163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=954163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=954163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}