{"id":797,"date":"2024-11-07T15:15:43","date_gmt":"2024-11-07T07:15:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/797\/"},"modified":"2024-11-07T15:15:43","modified_gmt":"2024-11-07T07:15:43","slug":"%e6%80%8e%e4%b9%88%e5%b0%86python%e7%88%ac%e8%99%ab%e6%89%93%e5%8c%85","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/797\/","title":{"rendered":"\u600e\u4e48\u5c06python\u722c\u866b\u6253\u5305"},"content":{"rendered":"<blockquote><p>\n  \u6253\u5305 python \u722c\u866b\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u4f7f\u7528 pyinstaller\uff1apyinstaller &#8211;onefile &#8211;windowed your_crawler.py\u4f7f\u7528 cx_freeze\uff1acxfreeze &#8211;target-dir dist your_crawler.py\u3002\n<\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1107\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/2024101816461678243.jpg\" width=\"800\" height=\"320\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/2024101816461678243.jpg 800w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/2024101816461678243-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/2024101816461678243-768x307.jpg 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/2024101816461678243-670x268.jpg 670w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" title=\"\u600e\u4e48\u5c06python\u722c\u866b\u6253\u5305\u63d2\u56fe\" alt=\"\u600e\u4e48\u5c06python\u722c\u866b\u6253\u5305\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u6253\u5305 Python \u722c\u866b<\/strong><\/p>\n<p><strong>\u6982\u8ff0<\/strong><\/p>\n<p>\u5c06 Python \u722c\u866b\u6253\u5305\u53ef\u4ee5\u65b9\u4fbf\u5730\u90e8\u7f72\u548c\u53d1\u5e03\u3002\u901a\u8fc7\u6253\u5305\uff0c\u4f60\u53ef\u4ee5\u5c06\u722c\u866b\u4ee3\u7801\u3001\u4f9d\u8d56\u9879\u548c\u5fc5\u8981\u6587\u4ef6\u6253\u5305\u6210\u5355\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5f52\u6863\u6587\u4ef6\u3002<\/p>\n<p><strong>\u65b9\u6cd5<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201cPython\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b<\/p>\n<p>\u6253\u5305 Python \u722c\u866b\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 pyinstaller<\/strong><\/p>\n<p>pyinstaller \u662f\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u5c06 Python \u811a\u672c\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5de5\u5177\u3002<\/p>\n<p>\u5b89\u88c5 pyinstaller\uff1a<\/p>\n<pre>pip install pyinstaller<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6253\u5305\u722c\u866b\uff1a<\/p>\n<pre>pyinstaller --onefile --windowed your_crawler.py<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528 cx_freeze<\/strong><\/p>\n<p>cx_freeze \u662f\u53e6\u4e00\u4e2a\u6d41\u884c\u7684 Python \u51bb\u7ed3\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\u548c Windows \u5b89\u88c5\u7a0b\u5e8f\u3002<\/p>\n<p>\u5b89\u88c5 cx_freeze\uff1a<\/p>\n<pre>pip install cx_freeze<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6253\u5305\u722c\u866b\uff1a<\/p>\n<pre>cxfreeze --target-dir dist your_crawler.py<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4<\/strong><\/p>\n<p><strong>\u4f7f\u7528 pyinstaller<\/strong><\/p>\n<ol>\n<li>\u786e\u4fdd\u722c\u866b\u4e0d\u4f7f\u7528\u4efb\u4f55\u4f9d\u8d56\u9879\u6216\u6587\u4ef6\uff0c\u6216\u8005\u5c06\u5b83\u4eec\u5305\u62ec\u5728\u4f60\u7684\u4ee3\u7801\u4e2d\u3002<\/li>\n<li>\u8fd0\u884c pyinstaller \u547d\u4ee4\uff0c\u6307\u5b9a &#8211;onefile \u53c2\u6570\u4ee5\u521b\u5efa\u4e00\u4e2a\u5355\u4e2a\u6587\u4ef6\uff0c&#8211;windowed \u53c2\u6570\uff08\u53ef\u9009\uff09\u4f7f\u5e94\u7528\u7a0b\u5e8f\u5728 Windows \u4e2d\u4ee5\u7a97\u53e3\u5316\u6a21\u5f0f\u8fd0\u884c\u3002<\/li>\n<\/ol>\n<p><strong>\u4f7f\u7528 cx_freeze<\/strong><\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a setup.py \u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u4f60\u7684\u722c\u866b\u811a\u672c\u3001\u4f9d\u8d56\u9879\u548c\u53ef\u6267\u884c\u6587\u4ef6\u8bbe\u7f6e\u7684\u914d\u7f6e\u3002<\/li>\n<li>\u8fd0\u884c cxfreeze \u547d\u4ee4\uff0c\u6307\u5b9a\u5305\u542b setup.py \u6587\u4ef6\u7684\u76ee\u5f55\u3002<\/li>\n<li>\u5982\u679c\u4f60\u9700\u8981 Windows \u5b89\u88c5\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528 &#8211;installers \u53c2\u6570\u3002<\/li>\n<\/ol>\n<p><strong>\u53ef\u9009\u6b65\u9aa4<\/strong><\/p>\n<ul>\n<li> <strong>\u6307\u5b9a\u56fe\u6807\uff1a<\/strong>\u53ef\u4ee5\u4f7f\u7528 &#8211;icon \u53c2\u6570\u6307\u5b9a\u5e94\u7528\u56fe\u6807\u3002<\/li>\n<li> <strong>\u6392\u9664\u6587\u4ef6\uff1a<\/strong>\u53ef\u4ee5\u4f7f\u7528 &#8211;exclude-module \u53c2\u6570\u6392\u9664\u4e0d\u9700\u8981\u6253\u5305\u7684\u6587\u4ef6\u6216\u6a21\u5757\u3002<\/li>\n<li> <strong>\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/strong>\u6253\u5305\u5b8c\u6210\u540e\uff0c\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5f52\u6863\u6587\u4ef6\uff0c\u6839\u636e\u4f60\u4f7f\u7528\u7684\u5de5\u5177\u548c\u8bbe\u7f6e\u800c\u5b9a\u3002<\/li>\n<li> <strong>\u90e8\u7f72\u722c\u866b\uff1a<\/strong>\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5f52\u6863\u6587\u4ef6\u590d\u5236\u5230\u76ee\u6807\u673a\u5668\u4e0a\uff0c\u5e76\u8fd0\u884c\u5b83\u4ee5\u6267\u884c\u722c\u866b\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5c06python\u722c\u866b\u6253\u5305\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6253\u5305 python \u722c\u866b\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u4f7f\u7528 pyinstaller\uff1apyinstaller &#8211;onefile &#8211;windowed your_crawler.py\u4f7f\u7528 cx_freeze\uff1acxfreeze &#8211;target-dir dist your_crawler.py\u3002 \u5982\u4f55\u6253\u5305 Python \u722c\u866b \u6982\u8ff0 \u5c06 Python \u722c\u866b\u6253\u5305\u53ef\u4ee5\u65b9\u4fbf\u5730\u90e8\u7f72\u548c\u53d1\u5e03\u3002\u901a\u8fc7\u6253\u5305\uff0c\u4f60\u53ef\u4ee5\u5c06\u722c\u866b\u4ee3\u7801\u3001\u4f9d\u8d56\u9879\u548c\u5fc5\u8981\u6587\u4ef6\u6253\u5305\u6210\u5355\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5f52\u6863\u6587\u4ef6\u3002 \u65b9\u6cd5 \u7acb\u5373\u5b66\u4e60\u201cPython\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b \u6253\u5305 Python \u722c\u866b\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a 1. \u4f7f\u7528 pyinstaller pyinstaller \u662f\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u5c06 Python \u811a\u672c\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5de5\u5177\u3002 \u5b89\u88c5 pyinstaller\uff1a pip install pyinstaller \u767b\u5f55\u540e\u590d\u5236 \u6253\u5305\u722c\u866b\uff1a pyinstaller &#8211;onefile &#8211;windowed your_crawler.py \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528 cx_freeze cx_freeze \u662f\u53e6\u4e00\u4e2a\u6d41\u884c\u7684 Python \u51bb\u7ed3\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\u548c Windows \u5b89\u88c5\u7a0b\u5e8f\u3002 \u5b89\u88c5 cx_freeze\uff1a pip install [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-797","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=797"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/797\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}