{"id":15,"date":"2026-01-09T23:23:18","date_gmt":"2026-01-09T15:23:18","guid":{"rendered":"https:\/\/www.junyi.site\/?p=15"},"modified":"2026-01-09T23:41:17","modified_gmt":"2026-01-09T15:41:17","slug":"windows%e7%b3%bb%e7%bb%9f%e4%b8%8b%ef%bc%8c%e4%bd%bf%e7%94%a8pyinstaller%e5%b0%86python%e4%bb%a3%e7%a0%81%e6%89%93%e5%8c%85%e4%b8%ba%e5%8f%af%e6%89%a7%e8%a1%8c%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/www.junyi.site\/index.php\/2026\/01\/09\/windows%e7%b3%bb%e7%bb%9f%e4%b8%8b%ef%bc%8c%e4%bd%bf%e7%94%a8pyinstaller%e5%b0%86python%e4%bb%a3%e7%a0%81%e6%89%93%e5%8c%85%e4%b8%ba%e5%8f%af%e6%89%a7%e8%a1%8c%e6%96%87%e4%bb%b6\/","title":{"rendered":"Windows\u7cfb\u7edf\u4e0b\u4f7f\u7528PyInstaller\u6253\u5305Python\u4ee3\u7801"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>pyinstaller -F -w -i favicon.ico --clean -n \u8f6f\u4ef6\u540d\u79f0 MypythonABC.py<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<p><strong>\u547d\u4ee4\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n<p>pyinstaller<\/p>\n\n\n\n<p>\u2014\u2014\u547d\u4ee4\u4e3b\u7a0b\u5e8f\uff0c\u542b\u4e49\uff1a\u8c03\u7528 Python \u7684\u6253\u5305\u5de5\u5177 PyInstaller\uff0c\u662f\u6574\u6761\u547d\u4ee4\u7684\u6838\u5fc3\u5f00\u5934\uff0c\u6240\u6709\u6253\u5305\u53c2\u6570\u90fd\u8ddf\u5728\u5b83\u540e\u9762\u3002<br><br>-F<br>\u2014\u2014\u6838\u5fc3\u6253\u5305\u53c2\u6570\u30fb\u77ed\u53c2\u6570\uff0c\u542b\u4e49 \/ \u4f5c\u7528\uff1a\u6253\u5305\u4e3a\u201c\u5355\u4e2a\u72ec\u7acb\u7684.exe \u53ef\u6267\u884c\u6587\u4ef6\u201d\uff0c\u65e0\u96f6\u6563\u7684\u6587\u4ef6\u5939\u548c\u6587\u4ef6\uff1b\u7f3a\u70b9\uff1a\u7a0b\u5e8f\u7b2c\u4e00\u6b21\u53cc\u51fb\u8fd0\u884c\u65f6\u4f1a\u7a0d\u6162(\u7cfb\u7edf\u4f1a\u5728\u540e\u53f0\u89e3\u538b\u4e34\u65f6\u6587\u4ef6)\uff0c\u540e\u7eed\u8fd0\u884c\u901f\u5ea6\u6b63\u5e38\u3002<\/p>\n\n\n\n<p><br>-w<br>\u2014\u2014GUI\u7a0b\u5e8f\u5fc5\u52a0\u30fb\u77ed\u53c2\u6570\uff0c\u542b\u4e49 \/ \u4f5c\u7528\uff1a\u8fd0\u884c exe \u65f6\uff0c\u9690\u85cf\u9ed1\u8272\u7684 Python \u63a7\u5236\u53f0 (cmd) \u7a97\u53e3\uff0c\u662f\u56fe\u5f62\u754c\u9762\u7a0b\u5e8f\u7684\u300c\u6807\u914d\u53c2\u6570\u300d\uff0c\u4e0d\u52a0\u8fd9\u4e2a\u53c2\u6570\u7684\u8bdd\uff0c\u8f6f\u4ef6\u8fd0\u884c\u65f6\u4f1a\u5f39\u51fa\u9ed1\u8272\u547d\u4ee4\u884c\u7a97\u53e3\uff0c\u9002\u7528\u6240\u6709\u5e26\u7a97\u53e3\u7684 GUI \u7a0b\u5e8f\uff1b\u5982\u679c\u662f\u7eaf\u63a7\u5236\u53f0\u7a0b\u5e8f(\u65e0\u7a97\u53e3\uff0c\u53ea\u6709\u9ed1\u7a97\u8f93\u51fa\u6587\u5b57)\uff0c\u5fc5\u987b\u5220\u9664\u8fd9\u4e2a\u53c2\u6570\uff0c\u5426\u5219\u7a0b\u5e8f\u8fd0\u884c\u540e\u65e0\u4efb\u4f55\u663e\u793a\u3002<\/p>\n<\/div>\n\n\n\n<p><br>-i favicon.ico<br>\u2014\u2014\u6307\u5b9a\u7a0b\u5e8f\u56fe\u6807\u30fb\u77ed\u53c2\u6570\uff0c\u542b\u4e49 \/ \u4f5c\u7528\uff1a\u4e3a\u6253\u5305\u540e\u7684.exe \u6587\u4ef6\u672c\u8eab \u8bbe\u7f6e\u663e\u793a\u56fe\u6807\uff0c\u8def\u5f84\u89c4\u5219\uff1afavicon.ico\u548c&#8221;MypythonABC.py&#8221;\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n\n\n\n<p>&#8211;clean<br>\u2014\u2014\u7eaf\u51c0\u6253\u5305\u30fb\u957f\u53c2\u6570\uff0c\u542b\u4e49 \/ \u4f5c\u7528\uff1a\u6253\u5305\u524d\uff0c\u81ea\u52a8\u6e05\u7a7a PyInstaller \u7684\u7f13\u5b58\u6587\u4ef6 + \u4e34\u65f6\u6587\u4ef6 + \u65e7\u6253\u5305\u4ea7\u7269\u3002<\/p>\n\n\n\n<p><br>-n \u8f6f\u4ef6\u540d\u79f0<br>\u2014\u2014\u81ea\u5b9a\u4e49\u8f6f\u4ef6\u6587\u4ef6\u540d\u30fb\u77ed\u53c2\u6570\uff0c\u542b\u4e49 \/ \u4f5c\u7528\uff1a\u6307\u5b9a\u6253\u5305\u540e\u751f\u6210\u7684.exe \u6587\u4ef6\u7684\u540d\u79f0\u3002<\/p>\n\n\n\n<p>MypythonABC.py<br>\u2014\u2014\u6253\u5305\u5165\u53e3\u6587\u4ef6\u30fb\u65e0\u53c2\u6570\u6807\u8bc6\uff0c\u542b\u4e49 \/ \u4f5c\u7528\uff1aPython \u4e3b\u7a0b\u5e8f\u6587\u4ef6(\u7a0b\u5e8f\u5165\u53e3)\uff0c\u662f\u547d\u4ee4\u7684\u300c\u6838\u5fc3\u76ee\u6807\u6587\u4ef6\u300d\uff0c\u6240\u6709\u6253\u5305\u903b\u8f91\u90fd\u56f4\u7ed5\u8fd9\u4e2a\u6587\u4ef6\u5c55\u5f00\uff0c\u6587\u4ef6\u540d\u4e0d\u8981\u6709\u4e2d\u6587 \/ \u7a7a\u683c\uff0c\u6bd4\u5982&#8221;\u6211\u7684\u7a0b\u5e8f.py&#8221;\u8981\u6539\u6210&#8221;MyProgram.py&#8221;\uff0c\u5426\u5219\u6253\u5305\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n<p><br>UPX \u52a0\u58f3 + \u538b\u7f29 + \u6df7\u6dc6<br>\u2014\u2014\u5c06UPX \u7684\u8def\u5f84\u6dfb\u52a0\u5230\u4e86 Windows \u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff0cPyInstaller \u6253\u5305\u65f6\u4f1a\u81ea\u52a8\u68c0\u6d4b\u7cfb\u7edf\u4e2d\u7684UPX\u5e76\u9759\u9ed8\u8c03\u7528 UPX\uff0c\u65e0\u9700\u624b\u52a8\u5199\u53c2\u6570\uff1b\u6838\u5fc3\u4f5c\u7528\uff1a\u65e0\u635f\u538b\u7f29 exe \u4f53\u79ef(\u538b\u7f29\u7387 30%~60%)\u4e14\u4e0d\u5f71\u54cd\u529f\u80fd\uff1b\u4e8c\u8fdb\u5236\u52a0\u58f3\u6df7\u6dc6\uff1b\u7eaf\u7eff\u8272\u52a0\u58f3\uff0c\u7a0b\u5e8f\u8fd0\u884c\u65e0\u4efb\u4f55\u5f02\u5e38\u3002<\/p>\n\n\n\n<p><br>\u5173\u95ed UPX \u7684\u65b9\u6cd5\uff1a\u5982\u679c\u7a0b\u5e8f\u52a0\u58f3\u540e\u95ea\u9000\uff0c\u53ea\u9700\u5728\u547d\u4ee4\u91cc\u8ffd\u52a0 &#8211;noupx \u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pyinstaller -F -w -i favicon.ico --key=123456abc --clean --noupx -n \u8f6f\u4ef6\u540d\u79f0 main_obf.py<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u547d\u4ee4\u53c2\u6570\uff1a pyinstaller \u2014\u2014\u547d\u4ee4\u4e3b\u7a0b\u5e8f\uff0c\u542b\u4e49\uff1a\u8c03\u7528 Python \u7684\u6253\u5305\u5de5\u5177 PyInstalle [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":5,"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":22,"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions\/22"}],"wp:attachment":[{"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.junyi.site\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}