{"id":974213,"date":"2024-12-27T06:03:20","date_gmt":"2024-12-26T22:03:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/974213.html"},"modified":"2024-12-27T06:03:23","modified_gmt":"2024-12-26T22:03:23","slug":"python%e5%a6%82%e4%bd%95%e6%89%93%e5%8c%85exe%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/974213.html","title":{"rendered":"python\u5982\u4f55\u6253\u5305exe\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24200030\/befe6cf1-1e4e-43f6-93fc-5a9e841dfa4a.webp\" alt=\"python\u5982\u4f55\u6253\u5305exe\u6587\u4ef6\" \/><\/p>\n<p><p> \u5f00\u5934\u6bb5\u843d\uff1a  <\/p>\n<\/p>\n<p><p>\u8981\u5c06Python\u811a\u672c\u6253\u5305\u6210\u53ef\u6267\u884c\u7684EXE\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982<strong>PyInstaller\u3001cx_Freeze\u3001py2exe<\/strong>\u3002\u8fd9\u4e9b\u5de5\u5177\u80fd\u591f\u5c06Python\u4ee3\u7801\u548c\u6240\u9700\u7684\u4f9d\u8d56\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u65b9\u4fbf\u5728\u6ca1\u6709\u5b89\u88c5Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u3002<strong>PyInstaller<\/strong>\u662f\u6700\u5e38\u7528\u7684\u5de5\u5177\uff0c\u56e0\u4e3a\u5b83\u652f\u6301\u591a\u5e73\u53f0\u548c\u5927\u591a\u6570Python\u5e93\u3002\u4f7f\u7528PyInstaller\u6253\u5305\u65f6\uff0c\u9996\u5148\u5b89\u88c5PyInstaller\uff0c\u7136\u540e\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528\u7b80\u5355\u7684\u547d\u4ee4\u5373\u53ef\u5b8c\u6210\u6253\u5305\u3002\u6b64\u5916\uff0cPyInstaller\u652f\u6301\u591a\u79cd\u914d\u7f6e\u9009\u9879\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7684\u9700\u6c42\uff0c\u6bd4\u5982\u9690\u85cf\u63a7\u5236\u53f0\u7a97\u53e3\u3001\u6dfb\u52a0\u56fe\u6807\u7b49\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528PyInstaller\u6765\u6253\u5305Python\u811a\u672c\uff0c\u5e76\u89e3\u51b3\u5e38\u89c1\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001PYINSTALLER\u6982\u8ff0  <\/p>\n<\/p>\n<p><p>PyInstaller\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u80fd\u591f\u5c06Python\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u652f\u6301Windows\u3001MacOS\u548cLinux\u5e73\u53f0\u3002\u5176\u4e3b\u8981\u4f18\u70b9\u5305\u62ec\u652f\u6301\u5927\u591a\u6570\u7684Python\u5e93\u3001\u80fd\u591f\u81ea\u52a8\u5206\u6790\u4f9d\u8d56\u3001\u63d0\u4f9b\u7b80\u5355\u7684\u547d\u4ee4\u884c\u63a5\u53e3\u7b49\u3002PyInstaller\u7684\u57fa\u672c\u539f\u7406\u662f\u901a\u8fc7\u5206\u6790Python\u811a\u672c\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u5c06\u6240\u6709\u9700\u8981\u7684\u6587\u4ef6\u6253\u5305\u5230\u4e00\u4e2a\u6587\u4ef6\u5939\u4e2d\uff0c\u6700\u7ec8\u751f\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u7684EXE\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>1.1\u3001\u5b89\u88c5PyInstaller  <\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528PyInstaller\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fddPython\u73af\u5883\u5df2\u7ecf\u5b89\u88c5\uff0c\u5e76\u4e14\u8bbe\u7f6e\u4e86\u5408\u9002\u7684\u8def\u5f84\u3002\u7136\u540e\u901a\u8fc7pip\u5b89\u88c5PyInstaller\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyinstaller<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8f93\u5165<code>pyinstaller<\/code>\u6765\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u5982\u679c\u663e\u793a\u51faPyInstaller\u7684\u5e2e\u52a9\u4fe1\u606f\uff0c\u5219\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p>1.2\u3001PyInstaller\u7684\u57fa\u672c\u7528\u6cd5  <\/p>\n<\/p>\n<p><p>PyInstaller\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller your_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d<code>your_script.py<\/code>\u4e3a\u9700\u8981\u6253\u5305\u7684Python\u811a\u672c\u3002\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cPyInstaller\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e24\u4e2a\u6587\u4ef6\u5939\uff1a<code>build<\/code>\u548c<code>dist<\/code>\u3002<code>build<\/code>\u6587\u4ef6\u5939\u7528\u4e8e\u5b58\u653e\u4e34\u65f6\u6587\u4ef6\uff0c\u800c<code>dist<\/code>\u6587\u4ef6\u5939\u5219\u5305\u542b\u6700\u7ec8\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001PYINSTALLER\u9ad8\u7ea7\u914d\u7f6e  <\/p>\n<\/p>\n<p><p>\u867d\u7136PyInstaller\u7684\u57fa\u672c\u7528\u6cd5\u5df2\u7ecf\u80fd\u591f\u6ee1\u8db3\u5927\u591a\u6570\u9700\u6c42\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5bf9\u6253\u5305\u8fc7\u7a0b\u8fdb\u884c\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\u3002PyInstaller\u63d0\u4f9b\u4e86\u591a\u79cd\u9009\u9879\uff0c\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u6216\u547d\u4ee4\u884c\u53c2\u6570\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<\/p>\n<p><p>2.1\u3001\u5355\u6587\u4ef6\u6253\u5305  <\/p>\n<\/p>\n<p><p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cPyInstaller\u4f1a\u5c06\u6240\u6709\u6587\u4ef6\u6253\u5305\u5230\u4e00\u4e2a\u6587\u4ef6\u5939\u4e2d\u3002\u5982\u679c\u9700\u8981\u5c06\u6240\u6709\u5185\u5bb9\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684EXE\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 your_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u9009\u9879\u4f1a\u5c06\u6240\u6709\u4f9d\u8d56\u548c\u811a\u672c\u6253\u5305\u6210\u4e00\u4e2a\u5355\u4e00\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u65b9\u4fbf\u5206\u53d1\u3002<\/p>\n<\/p>\n<p><p>2.2\u3001\u9690\u85cf\u63a7\u5236\u53f0\u7a97\u53e3  <\/p>\n<\/p>\n<p><p>\u5bf9\u4e8eGUI\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u80fd\u4e0d\u5e0c\u671b\u5728\u8fd0\u884c\u65f6\u5f39\u51fa\u63a7\u5236\u53f0\u7a97\u53e3\u3002\u53ef\u4ee5\u4f7f\u7528<code>--noconsole<\/code>\u9009\u9879\u9690\u85cf\u63a7\u5236\u53f0\u7a97\u53e3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --noconsole your_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528\u6b64\u9009\u9879\u540e\uff0c\u751f\u6210\u7684EXE\u6587\u4ef6\u5728\u8fd0\u884c\u65f6\u4e0d\u4f1a\u5f39\u51fa\u63a7\u5236\u53f0\u7a97\u53e3\u3002<\/p>\n<\/p>\n<p><p>2.3\u3001\u6dfb\u52a0\u56fe\u6807  <\/p>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7<code>--icon<\/code>\u9009\u9879\u4e3a\u751f\u6210\u7684EXE\u6587\u4ef6\u6dfb\u52a0\u81ea\u5b9a\u4e49\u56fe\u6807\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --icon=your_icon.ico your_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u786e\u4fdd\u63d0\u4f9b\u7684\u56fe\u6807\u6587\u4ef6\u4e3aICO\u683c\u5f0f\uff0c\u5e76\u4f4d\u4e8e\u6b63\u786e\u7684\u8def\u5f84\u4e0b\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u89e3\u51b3\u5e38\u89c1\u95ee\u9898  <\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528PyInstaller\u6253\u5305Python\u811a\u672c\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u5982\u6253\u5305\u5931\u8d25\u3001\u7f3a\u5c11\u6a21\u5757\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u7684\u5efa\u8bae\u3002<\/p>\n<\/p>\n<p><p>3.1\u3001\u6253\u5305\u5931\u8d25  <\/p>\n<\/p>\n<p><p>\u6253\u5305\u5931\u8d25\u53ef\u80fd\u662f\u7531\u4e8e\u73af\u5883\u914d\u7f6e\u4e0d\u6b63\u786e\u6216\u811a\u672c\u4e2d\u4f7f\u7528\u4e86\u4e0d\u517c\u5bb9\u7684\u6a21\u5757\u3002\u9996\u5148\uff0c\u786e\u4fddPython\u73af\u5883\u8bbe\u7f6e\u6b63\u786e\uff0c\u5e76\u4e14\u4f7f\u7528\u7684\u6a21\u5757\u7248\u672c\u4e0ePython\u7248\u672c\u517c\u5bb9\u3002\u5176\u6b21\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u65b0PyInstaller\u5230\u6700\u65b0\u7248\u672c\uff0c\u4ee5\u786e\u4fdd\u4f7f\u7528\u6700\u65b0\u7684\u529f\u80fd\u548c\u4fee\u590d\u3002<\/p>\n<\/p>\n<p><p>3.2\u3001\u7f3a\u5c11\u6a21\u5757  <\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728\u8fd0\u884c\u751f\u6210\u7684EXE\u6587\u4ef6\u65f6\u51fa\u73b0\u7f3a\u5c11\u6a21\u5757\u7684\u9519\u8bef\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u89e3\u51b3\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u68c0\u67e5\u811a\u672c\u4e2d\u662f\u5426\u4f7f\u7528\u4e86\u52a8\u6001\u5bfc\u5165\u7684\u6a21\u5757\u3002PyInstaller\u53ef\u80fd\u65e0\u6cd5\u81ea\u52a8\u68c0\u6d4b\u52a8\u6001\u5bfc\u5165\u7684\u6a21\u5757\uff0c\u53ef\u4ee5\u901a\u8fc7<code>--hidden-import<\/code>\u9009\u9879\u624b\u52a8\u6307\u5b9a\u8fd9\u4e9b\u6a21\u5757\u3002<\/li>\n<li>\u68c0\u67e5\u662f\u5426\u5728\u6253\u5305\u547d\u4ee4\u4e2d\u9057\u6f0f\u4e86\u5fc5\u8981\u7684\u9009\u9879\uff0c\u6bd4\u5982<code>--onefile<\/code>\u6216<code>--noconsole<\/code>\u3002<\/li>\n<li>\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u5e93\u90fd\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\uff0c\u5e76\u4e14\u5176\u8def\u5f84\u5305\u542b\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/li>\n<\/ul>\n<p><p>3.3\u3001EXE\u6587\u4ef6\u8fc7\u5927  <\/p>\n<\/p>\n<p><p>\u751f\u6210\u7684EXE\u6587\u4ef6\u8fc7\u5927\u53ef\u80fd\u662f\u56e0\u4e3a\u5305\u542b\u4e86\u4e0d\u5fc5\u8981\u7684\u6a21\u5757\u6216\u8d44\u6e90\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u4f18\u5316\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>--onefile<\/code>\u9009\u9879\uff0c\u5c06\u6240\u6709\u5185\u5bb9\u6253\u5305\u6210\u4e00\u4e2a\u5355\u4e00\u7684\u6587\u4ef6\uff0c\u4ee5\u51cf\u5c11\u4f53\u79ef\u3002<\/li>\n<li>\u68c0\u67e5<code>spec<\/code>\u6587\u4ef6\uff0c\u6392\u9664\u4e0d\u9700\u8981\u7684\u6a21\u5757\u548c\u8d44\u6e90\u3002<\/li>\n<li>\u8003\u8651\u4f7f\u7528\u538b\u7f29\u5de5\u5177\u5bf9\u751f\u6210\u7684EXE\u6587\u4ef6\u8fdb\u884c\u8fdb\u4e00\u6b65\u538b\u7f29\u3002<\/li>\n<\/ul>\n<p><p>\u56db\u3001CX_FREEZE\u4e0ePY2EXE  <\/p>\n<\/p>\n<p><p>\u9664\u4e86PyInstaller\u4e4b\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u5de5\u5177\u53ef\u4ee5\u7528\u4e8e\u5c06Python\u811a\u672c\u6253\u5305\u6210EXE\u6587\u4ef6\uff0c\u5982cx_Freeze\u548cpy2exe\u3002\u867d\u7136PyInstaller\u662f\u6700\u53d7\u6b22\u8fce\u7684\u5de5\u5177\uff0c\u4f46\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u548c\u73af\u5883\uff0c\u5176\u4ed6\u5de5\u5177\u4e5f\u53ef\u80fd\u662f\u5408\u9002\u7684\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><p>4.1\u3001CX_FREEZE  <\/p>\n<\/p>\n<p><p>cx_Freeze\u662f\u53e6\u4e00\u4e2a\u6d41\u884c\u7684Python\u6253\u5305\u5de5\u5177\uff0c\u652f\u6301Windows\u3001MacOS\u548cLinux\u5e73\u53f0\u3002\u4e0ePyInstaller\u76f8\u6bd4\uff0ccx_Freeze\u66f4\u6ce8\u91cd\u4e8e\u751f\u6210\u8de8\u5e73\u53f0\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4f7f\u7528cx_Freeze\u7684\u6b65\u9aa4\u4e0ePyInstaller\u7c7b\u4f3c\uff0c\u9700\u8981\u5148\u5b89\u88c5cx_Freeze\uff0c\u7136\u540e\u7f16\u5199\u4e00\u4e2a<code>setup.py<\/code>\u811a\u672c\u6765\u914d\u7f6e\u6253\u5305\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><p>4.2\u3001PY2EXE  <\/p>\n<\/p>\n<p><p>py2exe\u662f\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u5c06Python\u811a\u672c\u6253\u5305\u6210Windows\u5e73\u53f0\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5de5\u5177\u3002\u5b83\u4e0d\u652f\u6301\u8de8\u5e73\u53f0\u6253\u5305\uff0c\u4f46\u5728Windows\u5e73\u53f0\u4e0a\u975e\u5e38\u9ad8\u6548\u3002\u4f7f\u7528py2exe\u7684\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5py2exe\u3001\u7f16\u5199<code>setup.py<\/code>\u811a\u672c\u4ee5\u53ca\u8fd0\u884c\u6253\u5305\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u603b\u7ed3  <\/p>\n<\/p>\n<p><p>\u5c06Python\u811a\u672c\u6253\u5305\u6210EXE\u6587\u4ef6\u662f\u5206\u53d1Python\u5e94\u7528\u7a0b\u5e8f\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u901a\u8fc7\u5de5\u5177\u5982PyInstaller\u3001cx_Freeze\u548cpy2exe\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u3002PyInstaller\u662f\u6700\u5e38\u7528\u7684\u5de5\u5177\uff0c\u56e0\u5176\u591a\u5e73\u53f0\u652f\u6301\u548c\u6613\u7528\u6027\u800c\u53d7\u6b22\u8fce\u3002\u5728\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u73af\u5883\u914d\u7f6e\u548c\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ee5\u786e\u4fdd\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u3002\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u5e0c\u671b\u80fd\u591f\u5e2e\u52a9\u8bfb\u8005\u6210\u529f\u5730\u5c06Python\u811a\u672c\u6253\u5305\u6210EXE\u6587\u4ef6\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u5c06\u811a\u672c\u6253\u5305\u6210exe\u6587\u4ef6\uff1f<\/strong><br \/>\u8981\u5c06Python\u811a\u672c\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5982PyInstaller\u3001cx_Freeze\u6216py2exe\u7b49\u5de5\u5177\u3002PyInstaller\u662f\u6700\u5e38\u7528\u7684\u9009\u62e9\uff0c\u5b83\u652f\u6301\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf\u3002\u5b89\u88c5PyInstaller\u540e\uff0c\u53ea\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>pyinstaller your_script.py<\/code>\u5373\u53ef\u751f\u6210exe\u6587\u4ef6\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5728\u6253\u5305\u524d\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u9879\u90fd\u5305\u542b\u5728\u5185\u3002<\/p>\n<p><strong>\u6253\u5305exe\u6587\u4ef6\u65f6\u9700\u8981\u8003\u8651\u54ea\u4e9b\u4f9d\u8d56\u9879\uff1f<\/strong><br \/>\u5728\u6253\u5305Python\u811a\u672c\u65f6\uff0c\u786e\u4fdd\u6240\u6709\u7b2c\u4e09\u65b9\u5e93\u548c\u6a21\u5757\u90fd\u5305\u542b\u5728\u5185\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u4f7f\u7528PyInstaller\u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u68c0\u6d4b\u5927\u90e8\u5206\u4f9d\u8d56\u9879\uff0c\u4f46\u6709\u65f6\u60a8\u53ef\u80fd\u9700\u8981\u624b\u52a8\u6307\u5b9a\u4e00\u4e9b\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u5728.spec\u6587\u4ef6\u4e2d\u6dfb\u52a0hiddenimports\u53c2\u6570\u6765\u5b9e\u73b0\u3002\u6b64\u5916\uff0c\u786e\u4fdd\u5728\u6253\u5305\u524d\u6d4b\u8bd5\u811a\u672c\u4ee5\u786e\u4fdd\u6ca1\u6709\u9057\u6f0f\u4efb\u4f55\u5173\u952e\u4f9d\u8d56\u9879\u3002<\/p>\n<p><strong>\u6253\u5305\u540e\u7684exe\u6587\u4ef6\u5728\u5176\u4ed6\u8ba1\u7b97\u673a\u4e0a\u80fd\u6b63\u5e38\u8fd0\u884c\u5417\uff1f<\/strong><br \/>\u6253\u5305\u540e\u751f\u6210\u7684exe\u6587\u4ef6\u5728\u5176\u4ed6\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u517c\u5bb9\u6027\u95ee\u9898\u3002\u8fd9\u901a\u5e38\u53d6\u51b3\u4e8e\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u662f\u5426\u5b89\u88c5\u4e86\u6240\u9700\u7684\u8fd0\u884c\u65f6\u5e93\u6216Python\u73af\u5883\u3002\u4e3a\u4e86\u786e\u4fdd\u60a8\u7684exe\u6587\u4ef6\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u90fd\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u5efa\u8bae\u5c06\u6240\u6709\u5fc5\u8981\u7684DLL\u6587\u4ef6\u548c\u8d44\u6e90\u4e00\u8d77\u6253\u5305\uff0c\u6216\u8005\u5728\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5Python\u8fd0\u884c\u65f6\u548c\u6240\u9700\u7684\u4f9d\u8d56\u9879\u3002\u4f7f\u7528PyInstaller\u7684<code>--onefile<\/code>\u9009\u9879\u8fd8\u53ef\u4ee5\u5c06\u6240\u6709\u6587\u4ef6\u6253\u5305\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684exe\u6587\u4ef6\uff0c\u7b80\u5316\u5206\u53d1\u8fc7\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5f00\u5934\u6bb5\u843d\uff1a \u8981\u5c06Python\u811a\u672c\u6253\u5305\u6210\u53ef\u6267\u884c\u7684EXE\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982PyInstaller\u3001cx_Free [&hellip;]","protected":false},"author":3,"featured_media":974227,"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\/974213"}],"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=974213"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/974213\/revisions"}],"predecessor-version":[{"id":974228,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/974213\/revisions\/974228"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/974227"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=974213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=974213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=974213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}