{"id":6417,"date":"2023-09-26T12:18:45","date_gmt":"2023-09-26T04:18:45","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=6417"},"modified":"2023-09-26T12:18:45","modified_gmt":"2023-09-26T04:18:45","slug":"idle%e6%80%8e%e4%b9%88%e6%89%93%e5%8c%85exe%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/09\/26\/idle%e6%80%8e%e4%b9%88%e6%89%93%e5%8c%85exe%ef%bc%9f\/","title":{"rendered":"idle\u600e\u4e48\u6253\u5305exe\uff1f"},"content":{"rendered":"
\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4f7f\u7528Python\u7684IDLE\u8fdb\u884c\u7a0b\u5e8f\u5f00\u53d1\uff0c\u4ee5\u53ca\u5982\u4f55\u5c06Python\u811a\u672c\u6253\u5305\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff08.exe\uff09\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u8ba9\u6ca1\u6709\u5b89\u88c5Python\u73af\u5883\u7684\u7528\u6237\u4e5f\u80fd\u4f7f\u7528\u60a8\u7684\u7a0b\u5e8f\u3002<\/p>\n
IDLE \u662f Python \u7684\u5b98\u65b9\u96c6\u6210\u5f00\u53d1\u73af\u5883\u3002\u5177\u6709\u8f7b\u91cf\u5316\u3001\u6613\u7528\u7684\u7279\u70b9\uff0c\u9002\u5408 Python \u5165\u95e8\u8005\u8fdb\u884c\u7f16\u7a0b\u7ec3\u4e60\u3002IDLE \u63d0\u4f9b\u4e86\u57fa\u672c\u7684\u7f16\u8f91\u3001\u8c03\u8bd5\u548c\u8fd0\u884c\u4ee3\u7801\u529f\u80fd\u3002\u4e0b\u9762\u662f\u4f7f\u7528 IDLE \u6253\u5305 Python \u811a\u672c\u4e3a .exe \u6587\u4ef6\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n
**\u7b2c\u4e00\u6b65**\uff1a\u7f16\u5199 Python \u4ee3\u7801<\/p>\n
\u9996\u5148\uff0c\u6253\u5f00IDLE\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\uff08\u4f8b\u5982\uff1amy_script.py\uff09\uff0c\u5728\u5176\u4e2d\u7f16\u5199\u60a8\u7684\u4ee3\u7801\u3002\u5f53\u60a8\u7684\u7a0b\u5e8f\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u65f6\uff0c\u8bf7\u4fdd\u5b58\u5e76\u5173\u95edIDLE\u3002<\/p>\n
**\u7b2c\u4e8c\u6b65**\uff1a\u5b89\u88c5\u6253\u5305\u5de5\u5177<\/p>\n
\u5728\u6b64\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 PyInstaller \u5de5\u5177\u5c06 Python \u811a\u672c\u6253\u5305\u6210 .exe \u6587\u4ef6\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5 PyInstaller\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows \u7528\u6237\uff09\u6216 Terminal \u754c\u9762\uff08Mac \u548c Linux \u7528\u6237\uff09\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n
“`<\/p>\n
pip install pyi<\/p>\n
nstaller<\/p>\n “`<\/p>\n \u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5373\u53ef\u5f00\u59cb\u4f7f\u7528 PyInstaller\u3002<\/p>\n **\u7b2c\u4e09\u6b65**\uff1a\u4f7f\u7528 PyInstaller \u6253\u5305<\/p>\n \u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216 Terminal \u754c\u9762\u4e2d\uff0c\u5bfc\u822a\u81f3\u5b58\u653e Python \u811a\u672c\u7684\u6587\u4ef6\u5939\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u6253\u5305\uff1a<\/p>\n “`<\/p>\n pyinstaller –onefile my_script.py<\/p>\n “`<\/p>\n \u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u9700\u8981\u5c06 “my_script.py” \u66ff\u6362\u6210\u60a8\u7684 Python \u6587\u4ef6\u540d\u3002<\/p>\n \u4e0a\u8ff0\u547d\u4ee4\u4f1a\u4e3a\u60a8\u7684Python\u811a\u672c\u521b\u5efa\u4e00\u4e2a\u5355\u4e00\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08.exe\uff09\u3002\u8bf7\u8010\u5fc3\u7b49\u5f85\u6253\u5305\u8fc7\u7a0b\u5b8c\u6210\u3002<\/p>\n **\u7b2c\u56db\u6b65**\uff1a\u67e5\u627e\u751f\u6210\u7684 .exe \u6587\u4ef6<\/p>\n \u5b8c\u6210\u6253\u5305\u540e\uff0c\u60a8\u4f1a\u5728\u5f53\u524d\u811a\u672c\u6240\u5728\u76ee\u5f55\u4e0b\u7684 “dist” \u6587\u4ef6\u5939\u4e2d\u627e\u5230\u751f\u6210\u7684 .exe \u6587\u4ef6\u3002\u5c06\u6b64\u6587\u4ef6\u53d1\u9001\u7ed9\u5176\u4ed6\u7528\u6237\uff0c\u4ed6\u4eec\u5c06\u65e0\u9700\u5b89\u88c5 Python \u6216\u5176\u4ed6\u4f9d\u8d56\u9879\u5373\u53ef\u8fd0\u884c\u60a8\u7684\u7a0b\u5e8f\u3002<\/p>\n \u6253\u5305\u8fc7\u7a0b\u7684\u539f\u7406\u7b80\u4ecb\uff1a<\/p>\n PyInstaller \u662f\u4e00\u4e2a\u5c06 Python \u811a\u672c\u6253\u5305\u6210\u72ec\u7acb\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5de5\u5177\u3002\u5b83\u4f1a\u5206\u6790\u60a8\u7684\u811a\u672c\uff0c\u6536\u96c6\u6240\u6709\u5fc5\u8981\u7684\u4f9d\u8d56\u9879\uff08\u5982\u5e93\u3001\u6570\u636e\u6587\u4ef6\u7b49\uff09\uff0c\u5e76\u5c06\u8fd9\u4e9b\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u5355\u4e00\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5f53\u7528\u6237\u8fd0\u884c\u6b64 .exe \u6587\u4ef6\u65f6\uff0cPyInstaller \u4f1a\u81ea\u52a8\u89e3\u538b\u6240\u9700\u7684\u4f9d\u8d56\u9879\u5e76\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u7684 Python \u73af\u5883\uff0c\u7136\u540e\u8fd0\u884c\u60a8\u7684\u811a\u672c\u3002<\/p>\n \u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n 1. \u6253\u5305\u4e4b\u540e\u7684 .exe \u6587\u4ef6\u53ef\u80fd\u4f1a\u8f83\u5927\uff0c\u56e0\u4e3a\u5b83\u5305\u542b\u4e86\u5b8c\u6574\u7684 Pyth\u628a\u9875\u9762\u6253\u5305\u6210exe<\/a>on \u89e3\u91ca\u5668\u548c\u6240\u9700\u7684\u4f9d\u8d56\u5e93\u3002\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 UPX \u5de5\u5177\uff08https:\/\/upx.github.io\/\uff09\u8fdb\u884c\u8fdb\u4e00\u6b65\u538b\u7f29\u3002<\/p>\n<\/figure>\n<\/p>\n