{"id":7142,"date":"2024-02-22T14:36:23","date_gmt":"2024-02-22T06:36:23","guid":{"rendered":"https:\/\/white-night.club\/?p=7142"},"modified":"2024-02-22T19:41:34","modified_gmt":"2024-02-22T11:41:34","slug":"pg27","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2024\/02\/22\/pg27\/","title":{"rendered":"\u5c06python\u6587\u4ef6\u6253\u5305\u4e3aexe\u8fd0\u884c"},"content":{"rendered":"\n<p>\u9996\u5148\u9700\u8981\u901a\u8fc7pip\u5b89\u88c5pyinstaller<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(234, 191, 191, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"pip install pyinstaller\" style=\"color:#D4D4D4;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #DCDCAA\">pip<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">install<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">pyinstaller<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color has-link-color wp-elements-5ed90ded23a05c982074223541143f52\">\n<p>\u5e94\u7528\u573a\u666f<\/p>\n<cite><em>\u5206\u53d1\u7a0b\u5e8f<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u7b80\u5355\u6765\u8bf4\uff0cpyinstaller\u53ef\u4ee5\u5c06\u6307\u5b9a\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709python\u6587\u4ef6\uff0c\u53ca\u5176\u4f9d\u8d56\u5305\uff0c\u5168\u90e8\u6253\u5305\u6210\u4e00\u4e2aexe\uff0c\u4fd7\u79f0\u201call in one\u201d\u3002<\/p>\n\n\n\n<p>\u4e3b\u8981\u662f\u7528\u4e8e\u5185\u7f51\u7f51\u6216\u8005\u5206\u53d1\u7a0b\u5e8f\u7684\u573a\u666f\u3002\u5176\u4ed6\u7528\u6237\u7528\u4f60\u7684\u7a0b\u5e8f\u80af\u5b9a\u662f\u4e0d\u60f3\u518d\u81ea\u5df1\u989d\u5916\u505a\u64cd\u4f5c\u7684\uff0c\u6700\u597d\u5c31\u662f\u5f00\u7bb1\u5373\u7528\u3002\u66f4\u91cd\u8981\u7684\u662fpyinstaller\u6253\u5305\u540e\u7684exe\uff0c\u65e0\u9700python\u73af\u5883\u5c31\u80fd\u8fd0\u884c\uff0c\u53ef\u8c13\u662f\u8001\u5c11\u54b8\u5b9c\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color has-link-color wp-elements-1a1b27cdb8b2683884cb2a4dada4d0f3\">\n<p>\u4f7f\u7528\u65b9\u5f0f<\/p>\n<cite><em>&#8211;onefile &#8211;add-data<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u53ef\u4ee5\u53ea\u6253\u5305\u5355\u4e2apython\u6587\u4ef6<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(234, 191, 191, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"pyinstaller --onefile code.py\" style=\"color:#D4D4D4;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #DCDCAA\">pyinstaller<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">--onefile<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">code.py<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u6253\u5305\u591a\u4e2a\u6587\u4ef6\u3002\u6bd4\u5982\u4f60\u60f3\u5c06\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709python\u6587\u4ef6\u6253\u5305\u4e3a\u4e00\u4e2aexe\uff0c\u90a3\u4e48\u6b64\u65f6onefile\u6307\u5b9a\u7684python\u6587\u4ef6\u5c31\u662fexe\u7684\u201c\u5165\u53e3\u201d<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(234, 191, 191, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"pyinstaller --onefile entrance.py --add-data=&quot;.;.&quot;\" style=\"color:#D4D4D4;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #DCDCAA\">pyinstaller<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">--onefile<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">entrance.py<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">--add-data=<\/span><span style=\"color: #CE9178\">&quot;.;.&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u540e\u9762\u7684&#8211;add-data\u5206\u4e3a\u4e24\u90e8\u5206\uff0c\u5206\u53f7\u524d\u7684\u8868\u793a\u6e90\u5730\u5740\uff0c\u5373\u5c06source\u6587\u4ef6\u5939\u4e0b\u7684python\u6587\u4ef6\u5168\u90e8\u6253\u5305\u3002\u5206\u53f7\u540e\u9762\u7684\u8868\u793a\u76ee\u7684\u5730\u5740\uff0c\u5373\u5728dest\u6587\u4ef6\u5939\u5148\u65b0\u5efa\u4e00\u4e2adist\u6587\u4ef6\u5939\uff0c\u5728dist\u6587\u4ef6\u5939\u4e2d\u751f\u6210\u6253\u5305\u597d\u7684exe\uff08exe\u8def\u5f84\u4e3adist\/xxx.exe\uff09\u3002\u6b64\u65f6\u7684source\u548cdest\u6587\u4ef6\u5939\u90fd\u662f\u5f53\u524d\u6587\u4ef6\u5939&#8221;.&#8221;\u3002<\/p>\n\n\n\n<p>\u8fd8\u6709\u5176\u4ed6\u53c2\u6570\uff0c\u6bd4\u5982\u751f\u6210\u5e26GUI\u754c\u9762\u7684\u53c2\u6570-w\u7b49\u3002cmd\u76f4\u63a5\u8f93pyinstaller\u5c31\u80fd\u770b\u5230\u6240\u6709\u53ef\u7528\u53c2\u6570\u4e86\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color has-link-color wp-elements-b8e36842b84b74be6db891e03511115e\">\n<p>\u5176\u4ed6<\/p>\n<cite><em>\u5220dist\u548cbuild<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e0d\u8fc7\u8fd9\u4e1c\u897f\u6709\u65f6\u5019\u4f1a\u51fa\u95ee\u9898\uff0c\u751f\u6210package\u7684\u65f6\u5019\u4f1a\u5361\u4f4f\uff0c\u6309\u56de\u8f66\u952e\u4e5f\u6ca1\u7528\uff0c\u6211\u8fd8\u7279\u610f\u7b49\u4e86\u534a\u4e2a\u5c0f\u65f6\uff0c\u6700\u540e\u53ea\u80fdCtrl+C\u5f3a\u9000\u3002\u540e\u9762\u53d1\u73b0\u78b0\u5230\u8fd9\u79cd\u60c5\u51b5\u76f4\u63a5\u5220\u6389\u4e4b\u524d\u751f\u6210\u7684dist\u548cbuild\u6587\u4ef6\u5939\u5c31\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pyinstaller<\/p>\n","protected":false},"author":1,"featured_media":3838,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[136,33],"tags":[75],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/7142"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=7142"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/7142\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/3838"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=7142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=7142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=7142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}