{"id":1155010,"date":"2025-01-13T17:58:09","date_gmt":"2025-01-13T09:58:09","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1155010.html"},"modified":"2025-01-13T17:58:11","modified_gmt":"2025-01-13T09:58:11","slug":"python%e5%a6%82%e4%bd%95%e6%89%93%e5%8c%85exe%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1155010.html","title":{"rendered":"python\u5982\u4f55\u6253\u5305exe\u7a0b\u5e8f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25184504\/b6531a0d-055d-48fc-a880-cd9cf25ae691.webp\" alt=\"python\u5982\u4f55\u6253\u5305exe\u7a0b\u5e8f\" \/><\/p>\n<p><p> <strong>Python\u6253\u5305exe\u7a0b\u5e8f\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5176\u4e2d\u5e38\u7528\u7684\u5de5\u5177\u5305\u62ecPyInstaller\u3001cx_Freeze\u3001Py2exe\u3001Nuitka\u7b49\u3002\u5173\u952e\u6b65\u9aa4\u5305\u62ec\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3001\u5b89\u88c5\u5de5\u5177\u3001\u7f16\u5199\u6253\u5305\u811a\u672c\u3001\u914d\u7f6e\u6253\u5305\u9009\u9879\u3001\u6267\u884c\u6253\u5305\u547d\u4ee4\u3002\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u7684PyInstaller\u5de5\u5177\u7684\u4f7f\u7528\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001PyInstaller\u7b80\u4ecb\u53ca\u5b89\u88c5<\/p>\n<\/p>\n<p><p><strong>PyInstaller<\/strong> \u662f\u4e00\u4e2a\u5e7f\u6cdb\u4f7f\u7528\u7684Python\u6253\u5305\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5c06Python\u811a\u672c\u53ca\u5176\u4f9d\u8d56\u9879\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002PyInstaller\u652f\u6301Windows\u3001Mac OS X\u548cLinux\u64cd\u4f5c\u7cfb\u7edf\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570Python\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><p>\u8981\u5b89\u88c5PyInstaller\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyinstaller<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528PyInstaller\u6253\u5305Python\u811a\u672c<\/p>\n<\/p>\n<ol>\n<li><strong>\u7f16\u5199Python\u811a\u672c<\/strong><\/li>\n<\/ol>\n<p><p>\u9996\u5148\uff0c\u51c6\u5907\u4e00\u4e2a\u9700\u8981\u6253\u5305\u7684Python\u811a\u672c\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>hello.py<\/code>\u7684\u811a\u672c\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u57fa\u672c\u6253\u5305\u547d\u4ee4<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u5bfc\u822a\u5230\u5305\u542b<code>hello.py<\/code>\u811a\u672c\u7684\u76ee\u5f55\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u547d\u4ee4\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>dist<\/code>\u7684\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u6253\u5305\u4e3a\u5355\u4e2a\u53ef\u6267\u884c\u6587\u4ef6<\/strong><\/li>\n<\/ol>\n<p><p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cPyInstaller\u4f1a\u751f\u6210\u591a\u4e2a\u6587\u4ef6\u548c\u6587\u4ef6\u5939\u3002\u5982\u679c\u4f60\u5e0c\u671b\u751f\u6210\u4e00\u4e2a\u5355\u72ec\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>--onefile<\/code>\u9009\u9879\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --onefile hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6253\u5305\u5b8c\u6210\u540e\uff0c\u5355\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u4f1a\u4f4d\u4e8e<code>dist<\/code>\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u6dfb\u52a0\u56fe\u6807<\/strong><\/li>\n<\/ol>\n<p><p>\u4f60\u53ef\u4ee5\u4e3a\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u6dfb\u52a0\u4e00\u4e2a\u56fe\u6807\uff0c\u4f7f\u7528<code>--icon<\/code>\u9009\u9879\u6307\u5b9a\u56fe\u6807\u6587\u4ef6\u7684\u8def\u5f84\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --onefile --icon=myicon.ico hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"5\">\n<li><strong>\u7981\u7528\u63a7\u5236\u53f0\u7a97\u53e3<\/strong><\/li>\n<\/ol>\n<p><p>\u5982\u679c\u4f60\u4e0d\u5e0c\u671b\u5728\u8fd0\u884cGUI\u5e94\u7528\u7a0b\u5e8f\u65f6\u5f39\u51fa\u63a7\u5236\u53f0\u7a97\u53e3\uff0c\u53ef\u4ee5\u4f7f\u7528<code>--noconsole<\/code>\u9009\u9879\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --onefile --noconsole hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u914d\u7f6ePyInstaller<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528.spec\u6587\u4ef6<\/strong><\/li>\n<\/ol>\n<p><p>PyInstaller\u751f\u6210\u7684.spec\u6587\u4ef6\u5305\u542b\u4e86\u6253\u5305\u8fc7\u7a0b\u4e2d\u7684\u6240\u6709\u914d\u7f6e\u4fe1\u606f\u3002\u4f60\u53ef\u4ee5\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u4ee5\u81ea\u5b9a\u4e49\u6253\u5305\u9009\u9879\u3002\u4f8b\u5982\uff0c\u751f\u6210<code>hello.spec<\/code>\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --onefile hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u8f91\u751f\u6210\u7684.spec\u6587\u4ef6\uff0c\u6dfb\u52a0\u6216\u4fee\u6539\u6253\u5305\u9009\u9879\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u6253\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller hello.spec<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5305\u542b\u989d\u5916\u6570\u636e\u6587\u4ef6<\/strong><\/li>\n<\/ol>\n<p><p>\u5982\u679c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u989d\u5916\u7684\u6570\u636e\u6587\u4ef6\uff08\u5982\u914d\u7f6e\u6587\u4ef6\u3001\u56fe\u50cf\u7b49\uff09\uff0c\u4f60\u53ef\u4ee5\u5728.spec\u6587\u4ef6\u4e2d\u6307\u5b9a\u8fd9\u4e9b\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5728<code>Analysis<\/code>\u90e8\u5206\u6dfb\u52a0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">datas=[(&#39;data\/config.json&#39;, &#39;data&#39;)]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u5904\u7406\u4f9d\u8d56\u9879<\/p>\n<\/p>\n<ol>\n<li><strong>\u81ea\u52a8\u68c0\u6d4b\u4f9d\u8d56\u9879<\/strong><\/li>\n<\/ol>\n<p><p>PyInstaller\u4f1a\u81ea\u52a8\u68c0\u6d4b\u5e76\u5305\u542b\u5927\u591a\u6570\u4f9d\u8d56\u9879\uff0c\u4f46\u6709\u65f6\u53ef\u80fd\u4f1a\u9057\u6f0f\u4e00\u4e9b\u5e93\u3002\u4f60\u53ef\u4ee5\u5728.spec\u6587\u4ef6\u4e2d\u624b\u52a8\u6dfb\u52a0\u8fd9\u4e9b\u5e93\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u6392\u9664\u4e0d\u5fc5\u8981\u7684\u5e93<\/strong><\/li>\n<\/ol>\n<p><p>\u4e3a\u4e86\u51cf\u5c0f\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u5927\u5c0f\uff0c\u4f60\u53ef\u4ee5\u5728.spec\u6587\u4ef6\u4e2d\u6392\u9664\u4e0d\u5fc5\u8981\u7684\u5e93\u3002\u4f8b\u5982\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u9009\u9879\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">excludes=[&#39;tkinter&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/p>\n<\/p>\n<ol>\n<li><strong>\u7f3a\u5c11\u6a21\u5757\u9519\u8bef<\/strong><\/li>\n<\/ol>\n<p><p>\u5982\u679c\u5728\u6253\u5305\u8fc7\u7a0b\u4e2d\u9047\u5230\u7f3a\u5c11\u6a21\u5757\u7684\u9519\u8bef\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u624b\u52a8\u6dfb\u52a0\u8fd9\u4e9b\u6a21\u5757\u5230.spec\u6587\u4ef6\u7684<code>hiddenimports<\/code>\u5217\u8868\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">hiddenimports=[&#39;module1&#39;, &#39;module2&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u6587\u4ef6\u8def\u5f84\u95ee\u9898<\/strong><\/li>\n<\/ol>\n<p><p>\u6253\u5305\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u8fd0\u884c\u65f6\uff0c\u6587\u4ef6\u8def\u5f84\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u83b7\u53d6\u53ef\u6267\u884c\u6587\u4ef6\u7684\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>import os<\/p>\n<p>if getattr(sys, &#39;frozen&#39;, False):<\/p>\n<p>    application_path = os.path.dirname(sys.executable)<\/p>\n<p>else:<\/p>\n<p>    application_path = os.path.dirname(os.path.abspath(__file__))<\/p>\n<p>file_path = os.path.join(application_path, &#39;data\/config.json&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u5176\u4ed6\u6253\u5305\u5de5\u5177<\/p>\n<\/p>\n<ol>\n<li><strong>cx_Freeze<\/strong><\/li>\n<\/ol>\n<p><p>cx_Freeze\u662f\u53e6\u4e00\u4e2a\u5e38\u7528\u7684Python\u6253\u5305\u5de5\u5177\uff0c\u652f\u6301Windows\u548cLinux\u3002\u5b83\u7684\u4f7f\u7528\u65b9\u6cd5\u4e0ePyInstaller\u7c7b\u4f3c\uff0c\u4f46\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f\u4e0d\u540c\u3002\u5b89\u88c5cx_Freeze\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install cx_Freeze<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528cx_Freeze\u6253\u5305\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from cx_Freeze import setup, Executable<\/p>\n<p>setup(<\/p>\n<p>    name=&quot;hello&quot;,<\/p>\n<p>    version=&quot;0.1&quot;,<\/p>\n<p>    description=&quot;Hello World Application&quot;,<\/p>\n<p>    executables=[Executable(&quot;hello.py&quot;, base=&quot;Win32GUI&quot;, icon=&quot;myicon.ico&quot;)]<\/p>\n<p>)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u6253\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py build<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>Py2exe<\/strong><\/li>\n<\/ol>\n<p><p>Py2exe\u4e13\u95e8\u7528\u4e8e\u5c06Python\u811a\u672c\u6253\u5305\u6210Windows\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5b89\u88c5Py2exe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install py2exe<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u5199\u6253\u5305\u811a\u672c<code>setup.py<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from distutils.core import setup<\/p>\n<p>import py2exe<\/p>\n<p>setup(<\/p>\n<p>    console=[&#39;hello.py&#39;],<\/p>\n<p>    options={<\/p>\n<p>        &#39;py2exe&#39;: {<\/p>\n<p>            &#39;bundle_files&#39;: 1,<\/p>\n<p>            &#39;compressed&#39;: True<\/p>\n<p>        }<\/p>\n<p>    },<\/p>\n<p>    zipfile=None<\/p>\n<p>)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u6253\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py py2exe<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e03\u3001\u4f18\u5316\u6253\u5305\u7ed3\u679c<\/p>\n<\/p>\n<ol>\n<li><strong>\u51cf\u5c11\u6587\u4ef6\u5927\u5c0f<\/strong><\/li>\n<\/ol>\n<p><p>\u4e3a\u4e86\u51cf\u5c0f\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u5927\u5c0f\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>--strip<\/code>\u9009\u9879\u79fb\u9664\u4e0d\u5fc5\u8981\u7684\u7b26\u53f7\u4fe1\u606f\uff1a\n<pre><code class=\"language-bash\">pyinstaller --onefile --strip hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u4f7f\u7528<code>UPX<\/code>\u5de5\u5177\u538b\u7f29\u53ef\u6267\u884c\u6587\u4ef6\uff1a\n<pre><code class=\"language-bash\">pip install upx<\/p>\n<p>pyinstaller --onefile --upx-dir=C:\\path\\to\\upx hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<ol start=\"2\">\n<li><strong>\u63d0\u9ad8\u542f\u52a8\u901f\u5ea6<\/strong><\/li>\n<\/ol>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u542f\u52a8\u901f\u5ea6\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>--noconfirm<\/code>\u9009\u9879\u907f\u514d\u6bcf\u6b21\u6253\u5305\u65f6\u7684\u786e\u8ba4\u63d0\u793a\uff1a\n<pre><code class=\"language-bash\">pyinstaller --onefile --noconfirm hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u7f13\u5b58\u4f9d\u8d56\u9879\u4ee5\u52a0\u5feb\u6253\u5305\u8fc7\u7a0b\uff1a\n<pre><code class=\"language-bash\">pyinstaller --onefile --cachedir=C:\\path\\to\\cache hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u516b\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528PyInstaller\u6253\u5305Python\u7a0b\u5e8f\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u662f\u4e00\u79cd\u7b80\u5355\u800c\u6709\u6548\u7684\u65b9\u6cd5\u3002\u901a\u8fc7\u5408\u7406\u914d\u7f6e\u6253\u5305\u9009\u9879\u548c\u5904\u7406\u4f9d\u8d56\u9879\uff0c\u53ef\u4ee5\u751f\u6210\u9ad8\u8d28\u91cf\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5176\u4ed6\u6253\u5305\u5de5\u5177\u5982cx_Freeze\u548cPy2exe\u4e5f\u63d0\u4f9b\u4e86\u7c7b\u4f3c\u7684\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u3002<\/strong><\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5c06Python\u811a\u672c\u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u7684exe\u6587\u4ef6\uff1f<\/strong><br \/>\u8981\u5c06Python\u811a\u672c\u8f6c\u6362\u4e3aexe\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u6d41\u884c\u7684\u6253\u5305\u5de5\u5177\uff0c\u5982PyInstaller\u3001cx_Freeze\u6216py2exe\u3002\u4ee5PyInstaller\u4e3a\u4f8b\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u5b83\uff08\u901a\u8fc7\u547d\u4ee4<code>pip install pyinstaller<\/code>\uff09\uff0c\u7136\u540e\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>pyinstaller --onefile your_script.py<\/code>\uff0c\u751f\u6210\u7684exe\u6587\u4ef6\u4f1a\u5728<code>dist<\/code>\u6587\u4ef6\u5939\u4e2d\u627e\u5230\u3002<\/p>\n<p><strong>\u6253\u5305\u540e\u7684exe\u6587\u4ef6\u5728\u5176\u4ed6\u8ba1\u7b97\u673a\u4e0a\u80fd\u5426\u8fd0\u884c\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u6253\u5305\u540e\u7684exe\u6587\u4ef6\u53ef\u4ee5\u5728\u6ca1\u6709Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u3002\u4e0d\u8fc7\uff0c\u786e\u4fdd\u76ee\u6807\u8ba1\u7b97\u673a\u5177\u5907\u6240\u9700\u7684\u4f9d\u8d56\u5e93\u548c\u76f8\u5e94\u7684\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\uff0c\u4ee5\u907f\u514d\u8fd0\u884c\u9519\u8bef\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u6253\u5305\u65f6\u5305\u542b\u6240\u6709\u4f9d\u8d56\u9879\u6765\u51cf\u5c0f\u6b64\u7c7b\u95ee\u9898\u7684\u53ef\u80fd\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f18\u5316\u6253\u5305\u540e\u7684exe\u6587\u4ef6\u7684\u5927\u5c0f\uff1f<\/strong><br \/>\u6253\u5305\u540e\u7684exe\u6587\u4ef6\u53ef\u80fd\u4f1a\u5f88\u5927\uff0c\u7279\u522b\u662f\u5f53\u5305\u542b\u591a\u4e2a\u5e93\u65f6\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528PyInstaller\u7684<code>--exclude-module<\/code>\u9009\u9879\u6765\u6392\u9664\u4e0d\u5fc5\u8981\u7684\u6a21\u5757\uff0c\u6216\u8005\u4f7f\u7528<code>--onefile<\/code>\u9009\u9879\u5c06\u6240\u6709\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684exe\u3002\u6b64\u5916\uff0c\u6e05\u7406\u4e0d\u5fc5\u8981\u7684\u8d44\u6e90\u548c\u6587\u4ef6\u4e5f\u6709\u52a9\u4e8e\u51cf\u5c0f\u6700\u7ec8\u751f\u6210\u7684exe\u6587\u4ef6\u7684\u5927\u5c0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u6253\u5305exe\u7a0b\u5e8f\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5176\u4e2d\u5e38\u7528\u7684\u5de5\u5177\u5305\u62ecPyInstaller\u3001cx_Freeze\u3001Py2e [&hellip;]","protected":false},"author":3,"featured_media":1155016,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1155010"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1155010"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1155010\/revisions"}],"predecessor-version":[{"id":1155017,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1155010\/revisions\/1155017"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1155016"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1155010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1155010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1155010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}