{"id":19957,"date":"2025-05-04T12:22:06","date_gmt":"2025-05-04T04:22:06","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=19957"},"modified":"2025-05-04T21:12:38","modified_gmt":"2025-05-04T13:12:38","slug":"nuitka-2-7-0-%e4%b8%ad-sys-executable-%e5%92%8c-__file__-%e8%b7%af%e5%be%84%e6%94%b9%e4%ba%86","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=19957","title":{"rendered":"Nuitka 2.7.0 \u5355\u6587\u4ef6\u6253\u5305\u65f6 sys.executable \u548c __file__ \u8def\u5f84\u6709\u53d8\u5316"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.iyatt.com\/?p=19957\/#%E5%89%8D%E8%A8%80\" >\u524d\u8a00<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.iyatt.com\/?p=19957\/#%E6%B5%8B%E8%AF%95\" >\u6d4b\u8bd5<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.iyatt.com\/?p=19957\/#%E4%BB%A3%E7%A0%81\" >\u4ee3\u7801<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.iyatt.com\/?p=19957\/#Nuitka_269\" >Nuitka 2.6.9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.iyatt.com\/?p=19957\/#Nuitka_270\" >Nuitka 2.7.0<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E5%89%8D%E8%A8%80\"><\/span>\u524d\u8a00<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u6211\u5f00\u59cb\u4e00\u4e2a\u65b0\u9879\u76ee\u5c31\u662f\u4f7f\u7528\u5f53\u65f6\u6700\u65b0\u7248\u672c\u7684 Nuitka \u4f5c\u4e3a\u6253\u5305\u5de5\u5177\uff0c\u524d\u9762\u51e0\u4e2a\u6708\u8fd8\u662f 2.6.x \u7248\u672c\u7684\uff0c\u6700\u8fd1\u51e0\u5929\u53c8\u5728\u5199\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u73b0\u5728\u6700\u65b0\u7248\u7684 Nuitka \u662f 2.7.0\uff0c\u4f46\u662f\u6628\u665a\u53d1\u73b0 sys.executable \u8def\u5f84\u4e0d\u5bf9\u52b2\uff0c\u6700\u5f00\u59cb\u6211\u4ee5\u4e3a\u662f\u6211\u4ee3\u7801\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u6709\u4e9b\u6478\u4e0d\u7740\u5934\u8111\uff0c\u4eca\u5929\u7a81\u7136\u60f3\u5230\u662f\u4e0d\u662f Nuitka \u6539\u4e86\uff0c\u4e00\u6d4b\u8bd5\u8fd8\u771f\u7684\u662f\u6539\u4e86\u3002<\/p>\n<p>Nuitka \u5728\u6253\u5305\u7a0b\u5e8f\u4e3a\u5355\u6587\u4ef6\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd0\u884c\u6253\u5305\u7684\u7a0b\u5e8f\u65f6\u4f1a\u81ea\u52a8\u89e3\u538b\u91ca\u653e\u5230\u4e00\u4e2a\u4e34\u65f6\u6587\u4ef6\uff0c\u7136\u540e\u4ee5\u518d\u8fd0\u884c\u5b83\u3002\u5982\u679c\u7a0b\u5e8f\u8fd0\u884c\u4e2d\u8981\u4f7f\u7528\u5230\u4e00\u4e9b\u8d44\u6e90\u6587\u4ef6\uff0c\u6bd4\u5982\u8f6f\u4ef6\u56fe\u6807\u6587\u4ef6\uff0c\u5c31\u9700\u8981\u77e5\u9053\u7a0b\u5e8f\u91ca\u653e\u5230\u54ea\u4e2a\u76ee\u5f55\u4e86\uff0c\u8fd9\u6837\u624d\u80fd\u6b63\u786e\u8bfb\u53d6\u5230\u6587\u4ef6\u3002\u5728 2.6.x \u7248\u672c\u7684\u65f6\u5019\u6211\u5c31\u53d6 sys.executable \u7684\u76ee\u5f55\uff0c\u5c31\u662f\u91ca\u653e\u7684\u76ee\u5f55\uff0c\u7ed3\u679c\u6628\u665a\u5728 2.7.0 \u6d4b\u8bd5\u7684\u65f6\u5019\u62a5\u9519\u8bf4\u627e\u4e0d\u5230\u6587\u4ef6\u4e86\uff0c\u6211\u53d1\u73b0\u91cc\u9762\u50a8\u5b58\u7684\u8def\u5f84\u53d8\u6210\u4e86\u53ef\u6267\u884c\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\u4e86\uff0c\u800c\u4e0d\u662f\u8fd0\u884c\u65f6\u91ca\u653e\u7684\u76ee\u5f55\uff0c\u6240\u4ee5\u4eca\u5929\u5c31\u6709\u4e86\u4e0b\u9762\u7684\u6d4b\u8bd5\u3002<\/p>\n<h1><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95\"><\/span>\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u6d4b\u8bd5\u73af\u5883<\/p>\n<ul>\n<li>Windows 11 24H2<\/li>\n<li>Python 3.13.1<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E4%BB%A3%E7%A0%81\"><\/span>\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre><code class=\"language-python\">import sys\n\nprint(sys.argv)\nprint(sys.executable)\nprint(__file__)<\/code><\/pre>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/05\/image-1746330667199.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 525px; --smush-placeholder-aspect-ratio: 525\/103;\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Nuitka_269\"><\/span>Nuitka 2.6.9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5355\u6587\u4ef6\u6253\u5305<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/05\/image-1746331455479.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 493px; --smush-placeholder-aspect-ratio: 493\/97;\" \/><\/p>\n<p>\u591a\u6587\u4ef6\u6253\u5305<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/05\/image-1746331595922.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 566px; --smush-placeholder-aspect-ratio: 566\/78;\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Nuitka_270\"><\/span>Nuitka 2.7.0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5355\u6587\u4ef6\u6253\u5305<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/05\/image-1746331746720.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 564px; --smush-placeholder-aspect-ratio: 564\/71;\" \/><\/p>\n<p>\u591a\u6587\u4ef6\u6253\u5305<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2025\/05\/image-1746331796266.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 558px; --smush-placeholder-aspect-ratio: 558\/71;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u6211\u5f00\u59cb\u4e00\u4e2a\u65b0\u9879\u76ee\u5c31\u662f\u4f7f\u7528\u5f53\u65f6\u6700\u65b0\u7248\u672c\u7684 Nuitka \u4f5c\u4e3a\u6253\u5305\u5de5\u5177\uff0c\u524d\u9762\u51e0\u4e2a\u6708\u8fd8\u662f 2.6.x \u7248\u672c\u7684\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[1,592],"tags":[],"class_list":["post-19957","post","type-post","status-publish","format-standard","hentry","category-all","category-python"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19957"}],"version-history":[{"count":7,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19957\/revisions"}],"predecessor-version":[{"id":19992,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/19957\/revisions\/19992"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}