{"id":3535,"date":"2023-08-10T12:03:13","date_gmt":"2023-08-10T04:03:13","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=3535"},"modified":"2023-08-10T12:03:13","modified_gmt":"2023-08-10T04:03:13","slug":"pyinstaller%e6%89%93%e5%8c%85apk%e6%98%af%e6%80%8e%e4%b9%88%e4%b8%80%e4%bc%9a%e5%84%bf%e4%ba%8b%e5%84%bf%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/08\/10\/pyinstaller%e6%89%93%e5%8c%85apk%e6%98%af%e6%80%8e%e4%b9%88%e4%b8%80%e4%bc%9a%e5%84%bf%e4%ba%8b%e5%84%bf%ef%bc%9f\/","title":{"rendered":"pyinstaller\u6253\u5305apk\u662f\u600e\u4e48\u4e00\u4f1a\u513f\u4e8b\u513f\uff1f"},"content":{"rendered":"

PyInstaller\u662f\u4e00\u4e2a\u5c06Python\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u6210\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\u3001dmg\u3001apk\u7b49\uff09\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684\u6267\u884c\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u53ef\u4ee5\u5728\u6ca1\u6709Python\u89e3\u91ca\u5668\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\uff0c\u4f7f\u5f97Python\u7a0b\u5e8f\u7684\u53d1\u5e03\u548c\u4f7f\u7528\u53d8\u5f97\u66f4\u52a0\u7b80\u5355\u65b9\u4fbf\u3002<\/p>\n

PyInstaller\u6253\u5305apk\u7684\u539f\u7406\u662f\u5c06Python\u7a0b\u5e8f\u4ee5\u53ca\u76f8\u5173\u7684\u4f9d\u8d56\u5e93\u6253\u5305\u6210\u4e00\u4e2aapk\u6587\u4ef6\uff0c\u7136\u540e\u53ef\u4ee5\u5728Android\u8bbe\u5907\u4e0a\u8fdb\u884c\u5b89\u88c5\u548c\u8fd0\u884c\u3002\u4e0b\u9762\u662f\u8be6\u7ec6\u7684\u4ecb\u7ecd\uff1a<\/p>\n

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

\u9996\u5148\u9700\u8981\u5b89\u88c5PyInstaller\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n

“`<\/p>\n

pip install pyinstaller<\/p>\n

“`<\/p>\n

2. \u51c6\u5907Python\u7a0b\u5e8f<\/p>\n

\u51c6\u5907\u597d\u9700\u8981\u6253\u5305\u7684Python\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u662f\u4e00\u4e2a.py\u6587\u4ef6\u6216\u8005\u662f\u4e00\u4e2a\u5305\u542b\u591a\u4e2a.py\u6587\u4ef6\u7684\u9879\u76ee\u3002<\/p>\n

3. \u6267\u884cPyIn\u82f9\u679cipa\u6587\u4ef6\u81ea\u7b7e\u7f51\u5740<\/a>staller\u547d\u4ee4<\/p>\n

\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

pyinstaller –name=app –icon=app.ico –add-data=’resource;resource’ main.py<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0c–name\u53c2\u6570\u6307\u5b9a\u751f\u6210\u7684apk\u6587\u4ef6\u540d\u4e3aapp\uff0c–icon\u53c2\u6570\u6307\u5b9aapk\u56fe<\/p>\n

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

\u6807\u4e3aapp.ico\uff0c–add-data\u53c2\u6570\u6307\u5b9a\u9700\u8981\u6253\u5305\u7684\u8d44\u6e90\u6587\u4ef6\u5939\u4e3aresource\uff0cmain.py\u4e3a\u9700\u8981\u6253\u5305\u7684Python\u7a0b\u5e8f\u3002<\/p>\n

4. \u751f\u6210apk\u6587\u4ef6<\/p>\n

\u6267\u884c\u5b8c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cPyInstaller\u4f1a\u5728dist\u6587\u4ef6\u5939\u4e2d\u751f\u6210\u4e00\u4e2aapp\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u751f\u6210\u7684apk\u6587\u4ef6\u548c\u76f8\u5173\u7684\u4f9d\u8d56\u5e93\u3002\u53ef\u4ee5\u5c06\u8fd9\u4e2aapk\u6587\u4ef6\u5b89\u88c5\u5230Android\u8bbe\u5907\u4e2d\u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n

\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cPyInstaller\u6253\u5305apk\u9700\u8981\u5728\u5b89\u88c5\u4e86Android SDK\u548cNDK\u7684\u73af\u5883\u4e2d\u8fdb\u884c\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\u8fd9\u4e9b\u5de5\u5177\uff0c\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u5b89\u88c5\u548c\u914d\u7f6e\u3002<\/p>\n

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

PyIapk\u6253\u5305\u6a21\u5f0f\u6253\u5305<\/a>nstaller\u662f\u4e00\u4e2a\u975e\u5e38\u65b9\u4fbf\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5305\u62ecapk\u6587\u4ef6\u3002\u5b83\u7684\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c\u51e0\u6761\u547d\u4ee4\u5373\u53ef\u751f\u6210apk\u6587\u4ef6\u3002\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6253\u5305apk\u9700\u8981\u5728\u5b89\u88c5\u4e86Android SDK\u548cNDK\u7684\u73af\u5883\u4e2d\u8fdb\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

PyInstaller\u662f\u4e00\u4e2a\u5c06Python\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u6210\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\u3001dmg\u3001apk\u7b49\uff09\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684\u6267\u884c\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u53ef\u4ee5\u5728\u6ca1\u6709Python\u89e3\u91ca\u5668\u7684\u60c5<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7019,12,849,34,7020],"topic":[],"class_list":["post-3535","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-topvpn","tag-12","tag-849","tag-34","tag-7020"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/3535","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=3535"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/3535\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=3535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=3535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=3535"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=3535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}