{"id":18830,"date":"2024-03-15T09:42:47","date_gmt":"2024-03-15T01:42:47","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=18830"},"modified":"2024-03-15T09:42:47","modified_gmt":"2024-03-15T01:42:47","slug":"web%e9%a1%b9%e7%9b%ae%e5%a6%82%e4%bd%95%e6%89%93%e5%8c%85exe","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/18830\/","title":{"rendered":"web\u9879\u76ee\u5982\u4f55\u6253\u5305exe?"},"content":{"rendered":"

\u5728\u5c06web\u9879\u76ee\u6253\u5305\u6210exe\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u4e86\u89e3\u4e00\u4e9b\u5173\u4e8eweb\u548cexe\u7684\u57fa\u7840\u77e5\u8bc6\u3002<\/p>\n

Web\u662f\u6307\u901a\u8fc7\u4e92\u8054\u7f51\u8fdb\u884c\u4ea4\u4e92\u548c\u4fe1\u606f\u5171\u4eab\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u800cexe\u5219\u662f\u6307\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u662f\u4e00\u79cd\u5728\u8ba1\u7b97\u673a\u4e0a\u672c\u5730\u8fd0\u884c\u7684\u7a0b\u5e8f\u3002\u5728web\u5e94\u7528\u4e2d\uff0c\u7528\u6237\u9700\u8981\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668<\/p>\n

<\/figure>\n<\/p>\n

\u4e0a\u7684\u7f51\u9875\u6765\u5b9e\u73b0\u4ea4\u4e92\u548c\u4fe1\u606f\u5171\u4eab\uff0c\u800c\u5728exe\u7a0b\u5e8f\u4e2d\uff0c\u7528\u6237\u5219\u53ef\u4ee5\u76f4\u63a5\u5728\u672c\u5730\u8fd0\u884c\u7a0b\u5e8f\u6765\u5b9e\u73b0\u4ea4\u4e92\u548c\u4fe1\u606f\u5171\u4eab\u3002<\/p>\n

\u56e0\u6b64\uff0c\u5c06web\u9879\u76ee\u6253\u5305\u6210exe\u7684\u4e3b\u8981\u76ee\u7684\u662f\u4e3a\u4e86\u65b9\u4fbf\u7528\u6237\u5728\u672c\u5730\u8fd0\u884cweb\u5e94\u7528\uff0c\u800c\u4e0d\u5fc5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668\u4e0a\u7684\u7f51\u9875\u3002<\/p>\n

\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u7684\u7684\u65b9\u6cd5\u4e5f\u6709\u5f88\u591a\u79cd\uff0c\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\u6bd4\u8f83\u7b80\u5355\u7684\u65b9\u6cd5\uff1a<\/p>\n

1. \u4f7f\u7528pyinstaller\u6253\u5305exe<\/p>\n

pyinstaller\u662f\u4e00\u4e2a\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684\u7b2c\u4e09\u65b9\u5e93\u3002\u5b83\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u5355\u4e2aexe\u6587\u4ef6\uff0c\u65b9\u4fbf\u7528\u6237\u5728\u7f51\u9875\u5c01\u88c5\u6210exe\u6587\u4ef6\u7684\u8f6f\u4ef6<\/a>\u672c\u5730\u8fd0\u884c\u3002\u4e0b\u9762\u662f\u4f7f\u7528pyinstaller\u6253\u5305exe\u7684\u6b65\u9aa4\uff1a<\/p>\n

\uff081\uff09\u5b89\u88c5pyinstaller\u5e93<\/p>\n

\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\u5b89\u88c5pyinstaller\u5e93\uff1a<\/p>\n

pip install pyinstaller<\/p>\n

\uff082\uff09\u7f16\u5199Python\u7a0b\u5e8f<\/p>\n

\u5728\u7f16\u5199Python\u7a0b\u5e8f\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4e00\u4e9b\u95ee\u9898\uff0c\u6bd4\u5982\u8981\u5c06\u7a0b\u5e8f\u4e2d\u7684\u8def\u5f84\u7b49\u4fe1\u606f\u5199\u6210\u76f8\u5bf9\u8def\u5f84\uff0c\u907f\u514d\u51fa\u73b0\u6253\u5305\u540e\u65e0\u6cd5\u8fd0\u884c\u7684\u60c5\u51b5\u3002<\/p>\n

\uff083\uff09\u4f7f\u7528pyinstaller\u6253\u5305exe<\/p>\n

\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\u4f7f\u7528pyinstaller\u6253\u5305exe\uff1a<\/p>\n

pyinstaller -F xxx.py<\/p>\n

\u5176\u4e2d\uff0c-F\u53c2\u6570\u8868\u793a\u751f\u6210\u5355\u4e2aexe\u6587\u4ef6\uff0cxxx.py\u8868\u793a\u8981\u6253\u5305\u6210exe\u7684Python\u7a0b\u5e8f\u3002<\/p>\n

\uff084\uff09\u8fd0\u884cexe\u7a0b\u5e8f<\/p>\n

\u6253\u5305\u5b8c\u6210\u540e\uff0c\u5728dist\u76ee\u5f55\u4e0b\u53ef\u4ee5\u627e\u5230\u751f\u6210\u7684exe\u6587\u4ef6\uff0c\u53cc\u51fb\u5373\u53ef\u8fd0\u884c\u7a0b\u5e8f\u3002<\/p>\n

2. \u4f7f\u7528Electron\u6253\u5305exe<\/p>\n

Electron\u662f\u4e00\u4e2a\u57fa\u4e8eNode.js\u548cChromium\u7684\u6846\u67b6\uff0c\u53ef\u4ee5\u7528\u6765\u5f00\u53d1\u8de8\u5e73\u53f0\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528Electron\u6253\u5305exe\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

\uff081\uff09\u5b89\u88c5Electron<\/p>\n

\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\u5b89\u88c5Electron\uff1a<\/p>\n

npm install electron –save-dev<\/p>\n

\uff082\uff09\u7f16\u5199\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u4f7f\u7528Electron\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u9700\u8981\u7f16\u5199\u4e3b\u8fdb\u7a0b\u548c\u6e32\u67d3\u8fdb\u7a0b\u4e24\u4e2a\u90e8\u5206\u7684\u4ee3\u7801\uff0c\u4e3b\u8fdb\u7a0b\u8d1f\u8d23\u63a7\u5236\u6574\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u548c\u7a97\u53e3\u7ba1\u7406\uff0c\u6e32\u67d3\u8fdb\u7a0b\u8d1f\u8d23\u6e32\u67d3\u754c\u9762\u548c\u5904\u7406\u7528\u6237\u4ea4\u4e92\u3002<\/p>\n

\uff083\uff09\u6253\u5305\u6210exe\u7a0b\u5e8f<\/p>\n

\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\u4f7f\u7528Electron\u6253\u5305\u6210exe\u7a0b\u5e8f\uff1a<\/p>\n

electron-packager . myApp –platform=win32 –arch=x64 –icon=icon.ico<\/p>\n

\u5176\u4e2d\uff0c.\u8868\u793a\u5f53\u524d\u76ee\u5f55\uff0cmyApp\u8868\u793a\u751f\u6210\u7684exe\u6587\u4ef6\u540d\uff0c–platform\u53c2\u6570\u8868\u793a\u751f\u6210\u7684\u5e73\u53f0\uff0c–arch\u53c2\u6570\u8868\u793a\u751f\u6210\u7684\u67b6\u6784\uff0c–icon\u53c2\u6570\u8868\u793a\u7a0b\u5e8f\u56fe\u6807\u3002<\/p>\n

\uff084\uff09\u8fd0\u884cexe\u7a0b\u5e8f<\/p>\n

\u6253\u5305\u5b8c\u6210\u540e\uff0c\u5728\u751f\u6210\u7684myApp\u76ee\u5f55\u4e2d\u53ef\u4ee5\u627e\u5230\u751f\u6210\u7684exe\u6587\u4ef6\uff0c\u53cc\u51fb\u5373\u53ef\u8fd0\u884c\u7a0b\u5e8f\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

\u4ee5\u4e0a\u5c31\u662f\u4e24\u79cd\u5c06web\u9879\u76ee\u6253\u5305\u6210exe\u7684\u65b9\u6cd5\uff0c\u4f7f\u7528pyinstaller\u6253\u5305exe\u6bd4\u8f83\u7b80\u5355\uff0c\u9002\u5408\u6253\u5305Pytho\u5c06\u670d\u52a1\u5668\u6253\u5305\u6210exe<\/a>n\u7a0b\u5e8f\uff0c\u800c\u4f7f\u7528Electron\u6253\u5305exe\u5219\u53ef\u4ee5\u5f00\u53d1\u8de8\u5e73\u53f0\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u65e0\u8bba\u4f7f\u7528\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u9700\u8981\u6ce8\u610f\u7a0b\u5e8f\u4e2d\u7684\u8def\u5f84\u7b49\u4fe1\u606f\uff0c\u907f\u514d\u51fa\u73b0\u6253\u5305\u540e\u65e0\u6cd5\u8fd0\u884c\u7684\u60c5\u51b5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u5c06web\u9879\u76ee\u6253\u5305\u6210exe\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u4e86\u89e3\u4e00\u4e9b\u5173\u4e8eweb\u548cexe\u7684\u57fa\u7840\u77e5\u8bc6\u3002Web\u662f\u6307\u901a\u8fc7\u4e92\u8054\u7f51\u8fdb\u884c\u4ea4\u4e92\u548c\u4fe1\u606f\u5171\u4eab\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u800cexe\u5219\u662f\u6307\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u662f\u4e00\u79cd\u5728\u8ba1\u7b97\u673a\u4e0a\u672c\u5730\u8fd0\u884c\u7684\u7a0b\u5e8f\u3002\u5728web\u5e94<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14537,19502,12,91,89],"topic":[],"class_list":["post-18830","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-debugexe","tag-exeweb","tag-12","tag-91","tag-89"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=18830"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18830\/revisions"}],"predecessor-version":[{"id":18867,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18830\/revisions\/18867"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=18830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=18830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=18830"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=18830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}