{"id":825,"date":"2023-07-13T12:19:13","date_gmt":"2023-07-13T04:19:13","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=825"},"modified":"2023-07-13T12:19:13","modified_gmt":"2023-07-13T04:19:13","slug":"github%e6%89%93%e5%8c%85exe%e5%8f%af%e8%a1%8c%e5%98%9b%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/07\/13\/github%e6%89%93%e5%8c%85exe%e5%8f%af%e8%a1%8c%e5%98%9b%ef%bc%9f\/","title":{"rendered":"github\u6253\u5305exe\u53ef\u884c\u561b\uff1f"},"content":{"rendered":"

\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06\u4e00\u4e2aGitHub\u4ed3\u5e93\u6253\u5305\u6210\u4e00\u4e2aEXE\uff08\u53ef\u6267\u884c\u6587\u4ef6\uff09\uff0c\u8fd9\u5bf9\u4e8e\u9700\u8981\u5728\u4e0d\u540c\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u548c\u8fd0\u884c\u7684\u5f00\u53d1\u4eba\u5458\u548c\u6700\u7ec8\u7528\u6237\u975e\u5e38\u6709\u7528\u3002<\/p>\n

GitHub\u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u5e73\u53f0\uff0c\u5b9e\u9645\u4e0a\u5e76\u4e0d\u76f4\u63a5\u652f\u6301\u5c06\u4ed3\u5e93\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u5de5\u5177\u6765\u5b8c\u6210\u8fd9\u9879\u4efb\u52a1\uff0c\u6709\u4e24\u79cd\u5e38\u89c1\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\uff1a<\/p>\n

### \u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528PyInstaller\u5c06Python\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6<\/p>\n

\u5982\u679c\u4f60\u7684\u9879\u76ee\u662f\u7528Python\u7f16\u5199\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3cPyInstaller\u7684\u6253\u5305\u5de5\u5177\u5c06\u7a0b\u5e8f\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5728\u4e0d\u9700\u8981\u5b89\u88c5Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u3002<\/p>\n

1. \u5b89\u88c5PyInstaller\uff1a<\/p>\n

\u9996\u5148\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u73af\u5883\uff0c\u7136\u540e\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`shell<\/p>\n

pip install pyinstaller<\/p>\n

“`<\/p>\n

2. \u4eceGitHub\u4e0a\u514b\u9686\u4ed3\u5e93\u5230\u672c\u5730\uff1a<\/p>\n

“`shell<\/p>\n

git clone https:\/\/github.com\/username\/reponame<\/p>\n

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

.git<\/p>\n

cd reponame<\/p>\n

“`<\/p>\n

3. \u4f7f\u7528PyInstaller\u6253\u5305\u7a0b\u5e8f\uff1a<\/p>\n

“`shell<\/p>\n

pyinstaller –onefile your_python_script.py<\/p>\n

“`<\/p>\n

\u5176\u4e2d`your_python_script.py`\u662f\u5305\u542b\u4e3b\u8981\u6267\u884c\u903b\u8f91\u7684Python\u6587\u4ef6\u3002<\/p>\n

\u8fd9\u5c06\u5728`dist`\u6587\u4ef6\u5939\u4e2d\u751f\u6210\u4e00\u4e2aexe\u6587\u4ef6\uff08\u5728\u5f53\u524d\u64cd\u4f5c\u76ee\u5f55\u4e0b\uff09\uff0c\u4f60\u53ef\u4ee5\u5c06\u6b64\u6587\u4ef6\u53d1\u5e03\u7f51\u7ad9\u8f6c\u6362exe<\/a>\u7ed9\u6700\u7ec8\u7528\u6237\u3002<\/p>\n

### \u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528\u5f00\u6e90\u5de5\u5177Nuitka\u5c06Python\u9879\u76ee\u7f16\u8bd1\u6210EXE<\/p>\n

Nuitka\u662f\u4e00\u4e2aPython\u7f16\u8bd1\u5668\uff0c\u5b83\u53ef\u4ee5\u7f16\u8bd1Python\u6e90\u4ee3\u7801\u4e3a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u3002\u5b83\u6ca1\u6709\u6253\u5305\u5de5\u5177\u7684\u5f00\u9500\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u5b9a\u7a0b\u5ea6\u7684\u6027\u80fd\u4f18\u5316\u3002<\/p>\n

1. \u5b89\u88c5Nuitka\uff1a<\/p>\n

“`shell<\/p>\n

pip install nuitka<\/p>\n

“`<\/p>\n

2. \u5982\u679c\u4f60\u4f7f\u7528\u4e86\u4f9d\u8d56\u5916\u90e8\u5e93\uff0c\u8bf7\u786e\u4fdd\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u5b89\u88c5\u5b83\u4eec\u3002<\/p>\n

“`shell<\/p>\n

pip install -r requirements.txt<\/p>\n

“`<\/p>\n

3. \u4f7f\u7528Nuitka\u7f16\u8bd1Python\u6e90\u4ee3\u7801\uff1a<\/p>\n

“`shell<\/p>\n

nuitka –onefile –standalone your_python_script.py<\/p>\n

vs2019 exe\u7a0b\u5e8f\u6253\u5305<\/a>“`<\/p>\n

\u8fd9\u5c06\u751f\u6210\u4e00\u4e2a\u5355\u72ec\u7684EXE\u6587\u4ef6\uff0c\u53ef\u4ee5\u5728\u6ca1\u6709\u5b89\u88c5Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u3002<\/p>\n

\u5982\u679c\u4f60\u7684\u9879\u76ee\u4e0d\u662f\u7528Python\u7f16\u5199\u7684\uff0c\u4f60\u53ef\u80fd\u4f1a\u5bfb\u627e\u7c7b\u4f3c\u529f\u80fd\u7684\u7f16\u8bd1\u5668\/\u6253\u5305\u5de5\u5177\u3002<\/p>\n

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

GitHub\u672c\u8eab\u4e0d\u80fd\u76f4\u63a5\u5c06\u9879\u76ee\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4f46\u662f\u6709\u8bb8\u591a\u7b2c\u4e09\u65b9\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5b8c\u6210\u8fd9\u9879\u4efb\u52a1\u3002\u672c\u6559\u7a0b\u7b80\u8981\u4ecb\u7ecd\u4e86\u4e24\u79cd\u5c06Python\u9879\u76ee\u6253\u5305\u6210EXE\u6587\u4ef6\u7684\u65b9\u6cd5\u3002\u5bf9\u4e8e\u5176\u4ed6\u8bed\u8a00\u548c\u5e94\u7528\u7c7b\u578b\uff0c\u7c7b\u4f3c\u7684\u5de5\u5177\u548c\u65b9\u6cd5\u4e5f\u662f\u53ef\u7528\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06\u4e00\u4e2aGitHub\u4ed3\u5e93\u6253\u5305\u6210\u4e00\u4e2aEXE\uff08\u53ef\u6267\u884c\u6587\u4ef6\uff09\uff0c\u8fd9\u5bf9\u4e8e\u9700\u8981\u5728\u4e0d\u540c\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u548c\u8fd0\u884c\u7684\u5f00\u53d1\u4eba\u5458\u548c\u6700\u7ec8\u7528\u6237\u975e\u5e38\u6709\u7528\u3002GitHub\u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u5e73\u53f0\uff0c\u5b9e\u9645\u4e0a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1907,18,12,1906,588],"topic":[],"class_list":["post-825","post","type-post","status-publish","format-standard","hentry","category-zhuomianruanjian","tag-jar--exe","tag-18","tag-12","tag-exe","tag-588"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=825"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/825\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=825"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}