{"id":47425,"date":"2025-07-08T15:40:00","date_gmt":"2025-07-08T07:40:00","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/?p=47425"},"modified":"2025-07-08T15:40:00","modified_gmt":"2025-07-08T07:40:00","slug":"%e5%88%b6%e4%bd%9c%e7%8b%ac%e7%ab%8bexe%e6%93%8d%e4%bd%9c%e5%8a%9e%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2025\/47425\/","title":{"rendered":"\u5236\u4f5c\u72ec\u7acbexe\u64cd\u4f5c\u529e\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"

\u5236\u4f5c\u72ec\u7acbexe\u662f\u6307\u5c06\u4e00\u4e2a\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u8be5\u6587\u4ef6\uff0c\u800c\u4e0d\u9700\u8981\u5b89\u88c5\u4efb\u4f55\u5176\u4ed6\u4f9d\u8d56\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u65b9\u4fbf\u7528\u6237\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u4fdd\u62a4\u7a0b\u5e8f\u7684\u77e5\u8bc6\u4ea7\u6743\u3002\u4e0b\u9762\u4ecb\u7ecd\u51e0\u79cd\u5236\u4f5c\u72ec\u7acbexe\u7684\u65b9\u6cd5\u3002<\/p>\n

\u4e00\u3001\u4f7f\u7528pyinstaller<\/p>\n

pyinstaller\u662f\u4e00\u4e2aPython\u7b2c\u4e09\u65b9\u5e93\uff0c\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acb\u7684exe\u6587\u4ef6\u3002\u4f7f\u7528pyinstaller\u5236\u4f5c\u72ec\u7acbexe\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

1. \u5b89\u88c5pyinstaller\u5e93\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u201cpip install pyinstaller\u201d\u5373\u53ef\u5b89\u88c5\u3002<\/p>\n

2. \u6253\u5305\u7a0b\u5e8f\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u201cpyinstaller -F your_program.py\u201d\u5373\u53ef\u5c06your_program.py\u6587\u4ef6\u6253\u5305\u6210\u72ec\u7acbexe\u6587\u4ef6\u3002<\/p>\n

3. \u67e5\u770bexe\u6587\u4ef6\uff1a\u6253\u5305\u6210\u529f\u540e\uff0c\u53ef\u5728dist\u76ee\u5f55\u4e0b\u627e\u5230\u751f\u6210\u7684exe\u6587\u4ef6\u3002<\/p>\n

\u4e8c\u3001\u4f7f\u7528py2exe<\/p>\n

py2exe\u662f\u53e6\u4e00\u4e2a\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acbexe\u6587\u4ef6\u7684\u5de5\u5177\uff0c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n

1. \u5b89\u88c5py2exe\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u201cpip install py2<\/p>\n

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

exe\u201d\u5373\u53ef\u5b89\u88c5\u3002<\/p>\n

2. \u521b\u5efasetup.py\u6587\u4ef6\uff1a\u5728\u7a0b\u5e8f\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2asetup.py\u6587\u4ef6\uff0c\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

from distutils.core import setup<\/p>\n

import py2exe<\/p>\n

setup(conswin10\u684c\u9762\u5f00\u53d1<\/a>ole=[‘your_program.py’])<\/p>\n

“`<\/p>\n

3. \u6253\u5305\u7a0b\u5e8f\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u201cpython setup.py py2exe\u201d\u5373\u53ef\u5c06\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acbexe\u6587\u4ef6\u3002<\/p>\n

4. \u67e5\u770bexe\u6587\u4ef6\uff1a\u6253\u5305\u6210\u529f\u540e\uff0c\u53ef\u5728dist\u76ee\u5f55\u4e0b\u627e\u5230\u751f\u6210\u7684exe\u6587\u4ef6\u3002<\/p>\n

\u4e09\u3001\u4f7f\u7528cx_Freeze<\/p>\n

cx_Freeze\u662f\u53e6\u4e00\u4e2a\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acbexe\u6587\u4ef6\u7684\u5de5\u5177\uff0c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n

1. \u5b89\u88c5cx_Freeze\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u201cpip install cx_Freeze\u201d\u5373\u53ef\u5b89\u88c5\u3002<\/p>\n

2. \u521b\u5efasetup.py\u6587\u4ef6\uff1a\u5728\u7a0b\u5e8f\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2asetup.py\u6587\u4ef6\uff0c\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

import sys<\/p>\n

from cx_Freeze import setup, Executable<\/p>\n

build_exe_options = {“packages”: [“os”], “excludes”: [“tkinter”]}<\/p>\n

setup(<\/p>\n

name = “your_program_name”,<\/p>\n

version = “1.0”,<\/p>\n

description = “your_program_description”,<\/p>\n

options = {“build_exe”: build_exe_options},<\/p>\n

executables = [Executable(“your_program.py”, base=None)]<\/p>\n

)<\/p>\n

“`<\/p>\n

3. \u6253\u5305\u7a0b\u5e8f\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u201cpython setup.pyphp\u751f\u6210\u8f6f\u4ef6<\/a> build\u201d\u5373\u53ef\u5c06\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acbexe\u6587\u4ef6\u3002<\/p>\n

4. \u67e5\u770bexe\u6587\u4ef6\uff1a\u6253\u5305\u6210\u529f\u540e\uff0c\u53ef\u5728build\u76ee\u5f55\u4e0b\u627e\u5230\u751f\u6210\u7684exe\u6587\u4ef6\u3002<\/p>\n

\u603b\u7ed3<\/p>\n

\u4ee5\u4e0a\u4e09\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acbexe\u6587\u4ef6\uff0c\u4f7f\u7528\u8d77\u6765\u4e5f\u6bd4\u8f83\u7b80\u5355\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u5de5\u5177\u53ef\u4ee5\u5c06\u7a0b\u5e8f\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u5982py2app\u3001pyinstaller\u7b49\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6253\u5305\u6210\u72ec\u7acbexe\u6587\u4ef6\u65f6\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u4e00\u4e9b\u4f9d\u8d56\u95ee\u9898\uff0c\u9700\u8981\u5728\u6253\u5305\u524d\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\u3002\u540c\u65f6\uff0c\u6253\u5305\u540e\u7684exe\u6587\u4ef6\u4e5f\u53ef\u80fd\u4f1a\u88ab\u6740\u6bd2\u8f6f\u4ef6\u8bef\u62a5\uff0c\u56e0\u6b64\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u9632\u8bef\u62a5\u7684\u5904\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5236\u4f5c\u72ec\u7acbexe\u662f\u6307\u5c06\u4e00\u4e2a\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u8be5\u6587\u4ef6\uff0c\u800c\u4e0d\u9700\u8981\u5b89\u88c5\u4efb\u4f55\u5176\u4ed6\u4f9d\u8d56\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u65b9\u4fbf\u7528\u6237\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u4fdd\u62a4\u7a0b\u5e8f\u7684\u77e5\u8bc6\u4ea7\u6743\u3002\u4e0b\u9762\u4ecb\u7ecd\u51e0\u79cd\u5236\u4f5c\u72ec\u7acbexe\u7684\u65b9\u6cd5\u3002\u4e00<\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[2417,625,171,398,37403],"class_list":["post-47425","post","type-post","status-publish","format-standard","hentry","category-zuoexe","tag-windowsdeb","tag-625","tag-171","tag-398","tag-37403"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/47425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=47425"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/47425\/revisions"}],"predecessor-version":[{"id":47428,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/47425\/revisions\/47428"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=47425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=47425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=47425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}