{"id":222,"date":"2024-07-26T15:31:43","date_gmt":"2024-07-26T07:31:43","guid":{"rendered":"http:\/\/www.94i.top\/?p=222"},"modified":"2024-08-04T05:09:53","modified_gmt":"2024-08-03T21:09:53","slug":"python%e4%b9%8bnutika%e6%89%93%e5%8c%85","status":"publish","type":"post","link":"https:\/\/www.94i.top\/index.php\/2024\/07\/26\/python%e4%b9%8bnutika%e6%89%93%e5%8c%85\/","title":{"rendered":"Python\u4e4bNutika\u6253\u5305\u548cNSIS\u5b89\u88c5\u5305\u5236\u4f5c"},"content":{"rendered":"<h1>Nutika\u6253\u5305<\/h1>\n<h2>\u7f16\u5199\u6253\u5305\u547d\u4ee4<\/h2>\n<pre><code class=\"language-shell\">python -m nuitka --onefile --windows-console-mode=disable --enable-plugin=pyside6 --windows-icon-from-ico=wxassistant64_64.ico --remove-output main.py<\/code><\/pre>\n<h2>\u9047\u5230\u7684\u95ee\u9898<\/h2>\n<h3>[Errno 123] getWindowsLongPathName for d:\\program files (x86)\\tencent\\\u0004\u0004\u0004\u0004web\u0004\u0004\u0004\u0004\u0004\u0004\u0004\u0004\u0004\u0004\\dll\\ws2_32.dll<\/h3>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<br \/>\n\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u7684\u73af\u5883\u53d8\u91cf\u8ddfnuitka\u7684\u51b2\u7a81\uff0c\u5220\u9664\u6216\u6682\u65f6\u5c4f\u853d\u5f00\u53d1\u8005\u5de5\u5177\u7684\u73af\u5883\u53d8\u91cf<\/p>\n<h3>\u8fd0\u884c\u6253\u5305\u597d\u7684\u8f6f\u4ef6\u540e\u51fa\u73b0\u5f39\u51fa\u9ed1\u8272\u63a7\u5236\u53f0\u7684\u73b0\u8c61<\/h3>\n<p>\u901a\u8fc7\u67e5\u770b\u63a7\u5236\u53f0\u8fdb\u7a0b\u540d\u53d1\u73b0\u662fping.exe\u548cnetsh.exe\u7684\u5f39\u7a97\u3002<\/p>\n<h3>FATAL: Need to install 'imageio' to automatically convert the non native icon image (PNG) in file in<\/h3>\n<p>\u6253\u5305\u4f7f\u7528png\u4f5c\u4e3a\u56fe\u6807\u65f6\u62a5\u6b64\u9519\u8bef<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<br \/>\n\u5b89\u88c5imageio\u5e93<\/p>\n<pre><code class=\"language-shell\">pip install imageio<\/code><\/pre>\n<h1>\u5173\u4e8enuitka<\/h1>\n<h2>\u5e38\u7528\u9009\u9879<\/h2>\n<h3>\u901a\u7528\u9009\u9879<\/h3>\n<p><strong>\u2013standalone<\/strong> \u4f7f\u5f97\u6253\u5305\u7ed3\u679c\u4e0e\u672c\u5730\u7684Python\u73af\u5883\u65e0\u5173\uff0c\u5373\u4f7f\u5f97\u6253\u5305\u7ed3\u679c\u5177\u5907\u53ef\u79fb\u690d\u6027\u3002<br \/>\n<strong>\u2013onefile<\/strong> \u4f7f\u5f97\u6253\u5305\u7ed3\u679c\u4e3a\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u6587\u4ef6\u5939\u3002<br \/>\n\u5c0f\u7ed3\uff1a<strong>--onefile<\/strong>\u9009\u9879\u4e0b\u6253\u51fa\u6765\u7684\u5305\u672c\u8eab\u5c31\u5177\u5907\u53ef\u79fb\u690d\u6027\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u989d\u5916\u52a0\u4e0a <strong>--standalone<\/strong>\u3002<strong>--onefile<\/strong> \u6253\u5305\u7ed3\u679c\u50cf\u7eff\u8272\u8f6f\u4ef6\uff0c\u4ec5\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff1b<strong>--standalone<\/strong>\u7684\u6253\u5305\u7ed3\u679c\u50cf\u7ecf\u8fc7\u5b89\u88c5\u7684\u8f6f\u4ef6\uff0c\u6587\u4ef6\u5939\u4e0b\u5305\u542b\u8fd0\u884c\u6240\u9700\u8981\u7684\u6587\u4ef6\u548c\u7a0b\u5e8f\u5165\u53e3\u3002<\/p>\n<p><strong>\u2013remove-output<\/strong> \u5728\u6253\u5305\u7ed3\u675f\u540e\uff0c\u6e05\u7406\u6253\u5305\u8fc7\u7a0b\u4e2d\u751f\u6210\u7684\u4e34\u65f6\u6587\u4ef6\u3002<br \/>\n<strong>\u2013enable-plugin=<\/strong> \u542f\u7528\u63d2\u4ef6\uff0c\u7b49\u53f7\u540e\u8ddf\u63d2\u4ef6\u540d\u3002\u5728\u8981\u6253\u5305\u7684Python\u4ee3\u7801\u4f7f\u7528\u4e86\u4e00\u4e9b\u7279\u6b8a\u7684\u5305\u65f6\uff0c\u9700\u8981\u542f\u7528\u63d2\u4ef6\uff0cNuitka\u624d\u80fd\u591f\u6b63\u786e\u6253\u5305\u3002\u5982\uff1a\u5982\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86PySide6\uff0c\u5c31\u9700\u8981\u52a0\u4e0a<strong>--enable-plugin=pyside6<\/strong>\u3002\u5177\u4f53\u7684\u63d2\u4ef6\u5217\u8868\u53ef\u4ee5\u4f7f\u7528<code>nuitka --plugin-list<\/code>\u6765\u67e5\u770b\u3002<br \/>\n<strong>-\u2013disable-console<\/strong> \u5728\u8fd0\u884c\u6253\u5305\u540e\u7684\u7a0b\u5e8f\u65f6\uff0c\u4e0d\u4f1a\u5f39\u51fa\u63a7\u5236\u53f0\uff0c\u800c\u662f\u76f4\u63a5\u8fd0\u884cGUI\u7a0b\u5e8f\u3002<\/p>\n<h4>\u624b\u52a8\u4fee\u590d\u9009\u9879<\/h4>\n<p>\u6253\u5305\u7a0b\u5e8f\u5f80\u5f80\u5e76\u4e0d\u662f\u4e00\u6b21\u5c31\u80fd\u591f\u6253\u5305\u6210\u529f\u7684\uff0c\u5e38\u5e38\u4f1a\u51fa\u73b0\u5206\u6790\u4e0d\u51fa\u4e00\u90e8\u5206\u7684\u5f15\u7528\u5173\u7cfb\uff0c\u5ffd\u7565\u4e86\u4e00\u4e9b\u6570\u636e\u6587\u4ef6\u7b49\u7b49\u60c5\u51b5\u3002\u5728\u8fd9\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u9700\u8981\u6839\u636e\u8fd0\u884c\u7a0b\u5e8f\u540e\u663e\u793a\u7684\u62a5\u9519\u4fe1\u606f\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u9009\u9879\u6765\u6253\u51fa\u6b63\u786e\u7684\u5305\u3002<\/p>\n<p><strong>\u2013-include-package-data=<\/strong> \u5305\u542b\u7ed9\u5b9a\u8f6f\u4ef6\u5305\u540d\u79f0\u4e2d\u7684\u6570\u636e\u6587\u4ef6\uff0c\u7b49\u53f7\u540e\u8f6f\u4ef6\u5305\u540d\u79f0\u3002\u6709\u7684\u65f6\u5019Nuitka\u5e76\u4e0d\u80fd\u6b63\u786e\u5206\u6790\u51fa\u4e00\u4e9bPython\u8f6f\u4ef6\u5305\u6240\u9700\u8981\u4f7f\u7528\u7684\u6570\u636e\u6587\u4ef6\uff0c\u5728\u8fd0\u884c\u7a0b\u5e8f\u65f6\u63d0\u793aFileNotFoundError\u7b49\u9519\u8bef\uff0c\u6b64\u65f6\u5c31\u9700\u8981\u4f7f\u7528\u8be5\u9009\u9879\u3002\u5982\uff1a<strong>--include-package-data=ultralytics<\/strong><br \/>\n<strong>-\u2013include-data-files=<\/strong> \u6309\u6587\u4ef6\u540d\u5305\u542b\u6570\u636e\u6587\u4ef6\uff0c\u7b49\u53f7\u540e\u7684\u683c\u5f0f\u4e3a\u201dSRC=DEST\u201d\u3002SRC\u6307\u7684\u662f\u6587\u4ef6\u5939\u7684\u8def\u5f84\uff0cDEST\u6307\u7684\u662f\u6587\u4ef6\u5939\u76f8\u5bf9\u4e8e\u6253\u5305\u7ed3\u679c\u7684\u8def\u5f84\uff0c\u5176\u4e2dDEST\u53ea\u80fd\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u3002\u5982\uff1a<strong>--include-data-files=\/Users\/admin\/Downloads\/yolov5n.pt=.\/yolov5n.pt<\/strong><br \/>\n<strong>\u2013-include-data-dir=<\/strong> \u5305\u542b\u6587\u4ef6\u5939\u4e2d\u7684\u6570\u636e\u6587\u4ef6\uff0c\u7b49\u53f7\u540e\u7684\u683c\u5f0f\u4e3a\u201dSRC=DEST\u201d\u3002\u4f7f\u7528\u65b9\u6cd5\u4e0e<strong>--include-data-files=<\/strong>\u76f8\u540c\u3002<\/p>\n<h4>Windows \u72ec\u5360\u9009\u9879<\/h4>\n<p><strong>\u2013-windows-icon-from-ico=<\/strong> \u4e3a\u6253\u5305\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u6dfb\u52a0\u56fe\u6807\uff0c\u7b49\u53f7\u540e\u8ddf\u56fe\u6807\u6587\u4ef6\u8def\u5f84\u3002<br \/>\n\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u56fe\u6807\u7684\u683c\u5f0f\u4e5f\u53ef\u4ee5\u4e0d\u662f.ico\uff0c\u53ea\u9700\u8981\u5b89\u88c5\u8fc7imageio\u5305\uff0cNuitka\u4fbf\u53ef\u4ee5\u81ea\u52a8\u5c06\u56fe\u7247\u8f6c\u6362\u4e3a.ico\u683c\u5f0f\u3002<\/p>\n<h4>MacOS\u72ec\u5360\u9009\u9879<\/h4>\n<p><strong>-\u2013macos-create-app-bundle<\/strong> \u521b\u5efa\u5e94\u7528\u7a0b\u5e8f\uff08.app\uff09\uff0c\u800c\u4e0d\u662fUnix\u53ef\u6267\u884c\u6587\u4ef6\u3002\uff08\u622a\u81f3 Nuitka 1.5.3 \u8fd8\u662f\u5b9e\u9a8c\u6027\u529f\u80fd\uff0c\u53ef\u7528\u6027\u8f83\u4f4e\uff09<br \/>\n<strong>-\u2013macos-app-icon=<\/strong> \u8bbe\u7f6e\u5e94\u7528\u7a0b\u5e8f\u56fe\u6807\uff0c\u7b49\u53f7\u540e\u8ddf\u56fe\u6807\u6587\u4ef6\u8def\u5f84\u3002\u540c\u6837\uff0c\u56fe\u6807\u7684\u683c\u5f0f\u4e5f\u53ef\u4ee5\u4e0d\u662f.icns\uff0c\u53ea\u9700\u8981\u5b89\u88c5\u8fc7imageio\u5305\uff0cNuitka\u4fbf\u53ef\u4ee5\u81ea\u52a8\u5c06\u56fe\u7247\u8f6c\u6362\u4e3a.icns\u683c\u5f0f\u3002<br \/>\n\u65e0\u9700\u5173\u6ce8\u7684\u9009\u9879<br \/>\n<strong>\u2013-follow-imports<\/strong> \u4f5c\u7528\u662f\u5728\u6253\u5305\u8fc7\u7a0b\u4e2d\u5206\u6790\u7a0b\u5e8f\u7684\u5f15\u7528\u5173\u7cfb\uff0c\u5c06Python\u4e3b\u7a0b\u5e8f\u5f15\u7528\u7684\u5305\u4e5f\u4e00\u5e76\u6253\u5305\u3002\u5176\u5b9e\u8fd9\u4ef6\u4e8b\u672c\u8eab\u5f88\u91cd\u8981\uff0c\u6bd5\u7adf\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u5e94\u8be5\u6ca1\u4eba\u5e0c\u671bNuitka\u53ea\u6253\u5305\u4e00\u4e2aPython\u4e3b\u7a0b\u5e8f\u6587\u4ef6\u3002\u4f46\u662f\u5728 <strong>-\u2013standalone<\/strong> \u548c <strong>-\u2013onefile<\/strong> \u4e0b\uff0c\u8be5\u9009\u9879\u662f\u5f3a\u5236\u542f\u7528\u7684\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u989d\u5916\u52a0\u4e0a\u3002<br \/>\n<strong>-\u2013nofollow-import-to=<\/strong> \u4f5c\u7528\u662f\u5728\u6253\u5305\u8fc7\u7a0b\u4e2d\u5ffd\u7565\u6307\u5b9a\u7684Python\u8f6f\u4ef6\u5305\u3002\u4f5c\u4e3a\u5165\u95e8\u6307\u5357\uff0c\u6211\u4e0d\u5efa\u8bae\u4f7f\u7528\u8be5\u9009\u9879\uff0c\u56e0\u4e3a\u4e0d\u5f53\u4f7f\u7528\u4f1a\u5f15\u5165\u4e00\u4e9b\u96be\u4ee5\u89e3\u51b3\u7684\u95ee\u9898\u3002<\/p>\n<h4>\u5b9e\u7528\u547d\u4ee4<\/h4>\n<pre><code class=\"language-shell\">python -m nuitka --help # \u67e5\u770b Nuitka \u5e2e\u52a9\u624b\u518c\npython -m nuitka --plugin-list # \u67e5\u770b Nuitka \u63d2\u4ef6\u5217\u8868<\/code><\/pre>\n<h4>\u4e3e\u4f8b<\/h4>\n<pre><code class=\"language-shell\">python -m nuitka --standalone --remove-output {your_python_program_name}.py\npython -m nuitka --onefile --remove-output {your_python_program_name}.py\n\npython -m nuitka --standalone --disable-console --enable-plugin=pyside6 --remove-output {your_python_GUI_program_name}.py\npython -m nuitka --macos-create-app-bundle --disable-console --enable-plugin=pyside6 --remove-output {your_python_GUI_program_name}.py<\/code><\/pre>\n<h4>\u6ce8\u610f\u4e8b\u9879<\/h4>\n<p>\u5b98\u65b9\u6587\u6863\u4e2d\u63d0\u5230\uff0c\u76f8\u5bf9\u4e8e\u76f4\u63a5\u4f7f\u7528nuitka\u547d\u4ee4\uff0cpython -m nuitka\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002<br \/>\nAvoid running the nuitka binary, doing python -m nuitka will make a 100% sure you are using what you think you are. Using the wrong Python will make it give you SyntaxError for good code or ImportError for installed modules. That is happening, when you run Nuitka with Python2 on Python3 code and vice versa. By explicitly calling the same Python interpreter binary, you avoid that issue entirely.<\/p>\n<p>\u7528\u4e8e\u6267\u884cNuitka\u7684Python\u89e3\u91ca\u5668\u6700\u597d\u662fCPython\uff0c\u5373Python\u89e3\u91ca\u5668\u7684\u6807\u51c6\u5b9e\u73b0\u3002\u4f7f\u7528Apple Python\u7b49Python\u89e3\u91ca\u5668\u90e8\u5206\u529f\u80fd\u5c06\u53d7\u9650\u3002<br \/>\nIt has to be CPython, Anaconda Python.<\/p>\n<p>You need the standard Python implementation, called \u201cCPython\u201d, to execute Nuitka, because it is closely tied to implementation details of it.<\/p>\n<h3>\u4f18\u70b9<\/h3>\n<p>\u5bf9\u52a8\u6001\u94fe\u63a5\u5e93\u7684\u5206\u6790\u76f8\u5bf9\u51c6\u786e<br \/>\n\u6253\u5305\u751f\u6210\u7684\u8f6f\u4ef6\u5360\u7528\u7a7a\u95f4\u8f83\u5c0f<\/p>\n<h3>\u7f3a\u70b9<\/h3>\n<p>\u6253\u5305\u65f6\u95f4\u76f8\u5bf9\u8f83\u957f<br \/>\n\u6709\u5546\u4e1a\u7248\u672c\uff0c\u9700\u8981\u6536\u8d39<\/p>\n<h1>NSIS\u5b89\u88c5\u5305\u5236\u4f5c<\/h1>\n","protected":false},"excerpt":{"rendered":"<p>Nutika\u6253\u5305 \u7f16\u5199\u6253\u5305\u547d\u4ee4 python -m nuitka &#8211;onefile &#8211;windows-co [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-222","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/posts\/222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/comments?post=222"}],"version-history":[{"count":15,"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/posts\/222\/revisions"}],"predecessor-version":[{"id":263,"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/posts\/222\/revisions\/263"}],"wp:attachment":[{"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/media?parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/categories?post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.94i.top\/index.php\/wp-json\/wp\/v2\/tags?post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}