{"id":1119957,"date":"2025-01-08T18:49:54","date_gmt":"2025-01-08T10:49:54","guid":{"rendered":""},"modified":"2025-01-08T18:50:06","modified_gmt":"2025-01-08T10:50:06","slug":"%e5%a6%82%e4%bd%95%e5%81%9a%e4%b8%80%e4%b8%aapython-exe%e6%96%87%e4%bb%b6-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1119957.html","title":{"rendered":"\u5982\u4f55\u505a\u4e00\u4e2apython exe\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25082824\/e2938678-031b-4cb4-8f3b-b5c49d8a32c6.webp\" alt=\"\u5982\u4f55\u505a\u4e00\u4e2apython exe\u6587\u4ef6\" \/><\/p>\n<p><p> <strong>\u8981\u521b\u5efa\u4e00\u4e2aPython\u7684exe\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u8bf8\u5982PyInstaller\u3001cx_Freeze\u3001py2exe\u7b49\u5de5\u5177\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u5c06\u4f60\u7684Python\u811a\u672c\u8f6c\u6362\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u65b9\u4fbf\u5728\u6ca1\u6709Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a\u5b89\u88c5\u76f8\u5173\u5de5\u5177\u3001\u7f16\u5199Python\u811a\u672c\u3001\u4f7f\u7528\u5de5\u5177\u8fdb\u884c\u6253\u5305\u3001\u6d4b\u8bd5\u548c\u8c03\u8bd5\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4f7f\u7528PyInstaller\u8fdb\u884c\u64cd\u4f5c\u7684\u6b65\u9aa4\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5\u76f8\u5173\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u5728\u521b\u5efaPython exe\u6587\u4ef6\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5b89\u88c5\u76f8\u5173\u7684\u5de5\u5177\u3002PyInstaller\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5c06Python\u811a\u672c\u8f6c\u6362\u6210\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5PyInstaller\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyinstaller<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5b89\u88c5PyInstaller\u53ca\u5176\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u7f16\u5199Python\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728\u5c06Python\u811a\u672c\u8f6c\u6362\u6210exe\u6587\u4ef6\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u7f16\u5199\u4f60\u7684Python\u811a\u672c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># hello.py<\/p>\n<p>def m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n():<\/p>\n<p>    print(&quot;Hello, world!&quot;)<\/p>\n<p>if __name__ == &quot;__main__&quot;:<\/p>\n<p>    main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4fdd\u5b58\u5230\u4e00\u4e2a\u540d\u4e3ahello.py\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528PyInstaller\u8fdb\u884c\u6253\u5305<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u597dPyInstaller\u5e76\u7f16\u5199\u597dPython\u811a\u672c\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u5c06\u811a\u672c\u6253\u5305\u6210exe\u6587\u4ef6\u4e86\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u4f60\u7684Python\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\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>\u8fd9\u4e2a\u547d\u4ee4\u4f7f\u7528PyInstaller\u5c06hello.py\u811a\u672c\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684exe\u6587\u4ef6\u3002&#8211;onefile\u9009\u9879\u8868\u793a\u5c06\u6240\u6709\u4f9d\u8d56\u9879\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684exe\u6587\u4ef6\u3002\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cPyInstaller\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2adist\u76ee\u5f55\uff0c\u5176\u4e2d\u5305\u542b\u751f\u6210\u7684exe\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u6d4b\u8bd5\u548c\u8c03\u8bd5<\/p>\n<\/p>\n<p><p>\u751f\u6210exe\u6587\u4ef6\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u6ca1\u6709Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u5b83\u3002\u53ea\u9700\u5c06dist\u76ee\u5f55\u4e2d\u7684exe\u6587\u4ef6\u590d\u5236\u5230\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u5e76\u8fd0\u884c\u3002\u5982\u679cexe\u6587\u4ef6\u4e0d\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u4f60\u53ef\u4ee5\u67e5\u770bPyInstaller\u751f\u6210\u7684\u65e5\u5fd7\u6587\u4ef6\u6765\u8c03\u8bd5\u95ee\u9898\u3002\u4f60\u53ef\u4ee5\u5728\u751f\u6210\u7684build\u76ee\u5f55\u4e2d\u627e\u5230\u8fd9\u4e9b\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u6b65\u9aa4\u8bf4\u660e<\/strong><\/p>\n<\/p>\n<p><p>1\u3001\u5b89\u88c5\u76f8\u5173\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u73af\u5883\u3002\u4f60\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5b89\u88c5Python\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5PyInstaller\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyinstaller<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>2\u3001\u7f16\u5199Python\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728\u5c06Python\u811a\u672c\u8f6c\u6362\u6210exe\u6587\u4ef6\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u7f16\u5199\u4f60\u7684Python\u811a\u672c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># hello.py<\/p>\n<p>def main():<\/p>\n<p>    print(&quot;Hello, world!&quot;)<\/p>\n<p>if __name__ == &quot;__main__&quot;:<\/p>\n<p>    main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4fdd\u5b58\u5230\u4e00\u4e2a\u540d\u4e3ahello.py\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n<\/p>\n<p><p>3\u3001\u4f7f\u7528PyInstaller\u8fdb\u884c\u6253\u5305<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u597dPyInstaller\u5e76\u7f16\u5199\u597dPython\u811a\u672c\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u5c06\u811a\u672c\u6253\u5305\u6210exe\u6587\u4ef6\u4e86\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u4f60\u7684Python\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\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>\u8fd9\u4e2a\u547d\u4ee4\u4f7f\u7528PyInstaller\u5c06hello.py\u811a\u672c\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684exe\u6587\u4ef6\u3002&#8211;onefile\u9009\u9879\u8868\u793a\u5c06\u6240\u6709\u4f9d\u8d56\u9879\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684exe\u6587\u4ef6\u3002\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cPyInstaller\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2adist\u76ee\u5f55\uff0c\u5176\u4e2d\u5305\u542b\u751f\u6210\u7684exe\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>4\u3001\u6d4b\u8bd5\u548c\u8c03\u8bd5<\/p>\n<\/p>\n<p><p>\u751f\u6210exe\u6587\u4ef6\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u6ca1\u6709Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u5b83\u3002\u53ea\u9700\u5c06dist\u76ee\u5f55\u4e2d\u7684exe\u6587\u4ef6\u590d\u5236\u5230\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u5e76\u8fd0\u884c\u3002\u5982\u679cexe\u6587\u4ef6\u4e0d\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u4f60\u53ef\u4ee5\u67e5\u770bPyInstaller\u751f\u6210\u7684\u65e5\u5fd7\u6587\u4ef6\u6765\u8c03\u8bd5\u95ee\u9898\u3002\u4f60\u53ef\u4ee5\u5728\u751f\u6210\u7684build\u76ee\u5f55\u4e2d\u627e\u5230\u8fd9\u4e9b\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u6b65\u9aa4\u8bf4\u660e<\/strong><\/p>\n<\/p>\n<p><p>1\u3001\u5b89\u88c5\u76f8\u5173\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u73af\u5883\u3002\u4f60\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5b89\u88c5Python\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5PyInstaller\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyinstaller<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>2\u3001\u7f16\u5199Python\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728\u5c06Python\u811a\u672c\u8f6c\u6362\u6210exe\u6587\u4ef6\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u7f16\u5199\u4f60\u7684Python\u811a\u672c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># hello.py<\/p>\n<p>def main():<\/p>\n<p>    print(&quot;Hello, world!&quot;)<\/p>\n<p>if __name__ == &quot;__main__&quot;:<\/p>\n<p>    main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4fdd\u5b58\u5230\u4e00\u4e2a\u540d\u4e3ahello.py\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n<\/p>\n<p><p>3\u3001\u4f7f\u7528PyInstaller\u8fdb\u884c\u6253\u5305<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u597dPyInstaller\u5e76\u7f16\u5199\u597dPython\u811a\u672c\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u5c06\u811a\u672c\u6253\u5305\u6210exe\u6587\u4ef6\u4e86\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u4f60\u7684Python\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\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>\u8fd9\u4e2a\u547d\u4ee4\u4f7f\u7528PyInstaller\u5c06hello.py\u811a\u672c\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684exe\u6587\u4ef6\u3002&#8211;onefile\u9009\u9879\u8868\u793a\u5c06\u6240\u6709\u4f9d\u8d56\u9879\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684exe\u6587\u4ef6\u3002\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cPyInstaller\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2adist\u76ee\u5f55\uff0c\u5176\u4e2d\u5305\u542b\u751f\u6210\u7684exe\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>4\u3001\u6d4b\u8bd5\u548c\u8c03\u8bd5<\/p>\n<\/p>\n<p><p>\u751f\u6210exe\u6587\u4ef6\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u6ca1\u6709Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u5b83\u3002\u53ea\u9700\u5c06dist\u76ee\u5f55\u4e2d\u7684exe\u6587\u4ef6\u590d\u5236\u5230\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u5e76\u8fd0\u884c\u3002\u5982\u679cexe\u6587\u4ef6\u4e0d\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u4f60\u53ef\u4ee5\u67e5\u770bPyInstaller\u751f\u6210\u7684\u65e5\u5fd7\u6587\u4ef6\u6765\u8c03\u8bd5\u95ee\u9898\u3002\u4f60\u53ef\u4ee5\u5728\u751f\u6210\u7684build\u76ee\u5f55\u4e2d\u627e\u5230\u8fd9\u4e9b\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u6b65\u9aa4\u8bf4\u660e<\/strong><\/p>\n<\/p>\n<p><p>1\u3001\u5b89\u88c5\u76f8\u5173\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u73af\u5883\u3002\u4f60\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5b89\u88c5Python\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5PyInstaller\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyinstaller<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>2\u3001\u7f16\u5199Python\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728\u5c06Python\u811a\u672c\u8f6c\u6362\u6210exe\u6587\u4ef6\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u7f16\u5199\u4f60\u7684Python\u811a\u672c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># hello.py<\/p>\n<p>def main():<\/p>\n<p>    print(&quot;Hello, world!&quot;)<\/p>\n<p>if __name__ == &quot;__main__&quot;:<\/p>\n<p>    main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4fdd\u5b58\u5230\u4e00\u4e2a\u540d\u4e3ahello.py\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n<\/p>\n<p><p>3\u3001\u4f7f\u7528PyInstaller\u8fdb\u884c\u6253\u5305<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u597dPyInstaller\u5e76\u7f16\u5199\u597dPython\u811a\u672c\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u5c06\u811a\u672c\u6253\u5305\u6210exe\u6587\u4ef6\u4e86\u3002\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u4f60\u7684Python\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\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>\u8fd9\u4e2a\u547d\u4ee4\u4f7f\u7528PyInstaller\u5c06hello.py\u811a\u672c\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684exe\u6587\u4ef6\u3002&#8211;onefile\u9009\u9879\u8868\u793a\u5c06\u6240\u6709\u4f9d\u8d56\u9879\u6253\u5305\u6210\u4e00\u4e2a\u5355\u72ec\u7684exe\u6587\u4ef6\u3002\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0cPyInstaller\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2adist\u76ee\u5f55\uff0c\u5176\u4e2d\u5305\u542b\u751f\u6210\u7684exe\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>4\u3001\u6d4b\u8bd5\u548c\u8c03\u8bd5<\/p>\n<\/p>\n<p><p>\u751f\u6210exe\u6587\u4ef6\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u6ca1\u6709Python\u73af\u5883\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u5b83\u3002\u53ea\u9700\u5c06dist\u76ee\u5f55\u4e2d\u7684exe\u6587\u4ef6\u590d\u5236\u5230\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u5e76\u8fd0\u884c\u3002\u5982\u679cexe\u6587\u4ef6\u4e0d\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u4f60\u53ef\u4ee5\u67e5\u770bPyInstaller\u751f\u6210\u7684\u65e5\u5fd7\u6587\u4ef6\u6765\u8c03\u8bd5\u95ee\u9898\u3002\u4f60\u53ef\u4ee5\u5728\u751f\u6210\u7684build\u76ee\u5f55\u4e2d\u627e\u5230\u8fd9\u4e9b\u65e5\u5fd7\u6587\u4ef6\u3002<\/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\u6587\u4ef6\uff1f<\/strong><br \/>\u8981\u5c06Python\u811a\u672c\u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff08EXE\uff09\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u50cfPyInstaller\u6216cx_Freeze\u8fd9\u6837\u7684\u5de5\u5177\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u5c06\u4f60\u7684Python\u4ee3\u7801\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u72ec\u7acb\u8fd0\u884c\u7684EXE\u6587\u4ef6\u3002\u4f7f\u7528PyInstaller\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5PyInstaller\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u8fdb\u5165\u4f60\u7684\u811a\u672c\u6240\u5728\u76ee\u5f55\uff0c\u8fd0\u884c<code>pyinstaller --onefile your_script.py<\/code>\uff0c\u7136\u540e\u5728\u751f\u6210\u7684<code>dist<\/code>\u6587\u4ef6\u5939\u4e2d\u627e\u5230\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p><strong>\u8f6c\u6362\u540e\u7684EXE\u6587\u4ef6\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u53ef\u4ee5\u4f7f\u7528\u5417\uff1f<\/strong><br \/>\u751f\u6210\u7684EXE\u6587\u4ef6\u662fWindows\u7279\u6709\u7684\uff0c\u65e0\u6cd5\u5728Mac\u6216Linux\u7cfb\u7edf\u4e0a\u76f4\u63a5\u8fd0\u884c\u3002\u5982\u679c\u60f3\u8981\u5728\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u4f7f\u7528\uff0c\u5efa\u8bae\u4e3a\u6bcf\u79cd\u64cd\u4f5c\u7cfb\u7edf\u5206\u522b\u521b\u5efa\u5bf9\u5e94\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5728Linux\u4e0a\u53ef\u4ee5\u4f7f\u7528AppImage\u7b49\u5de5\u5177\uff0c\u800c\u5728Mac\u4e0a\u53ef\u4ee5\u4f7f\u7528Py2app\u7b49\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u751f\u6210EXE\u6587\u4ef6\u540e\uff0c\u662f\u5426\u9700\u8981\u5728\u76ee\u6807\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5Python\u73af\u5883\uff1f<\/strong><br \/>\u4e0d\u9700\u8981\u3002\u4f7f\u7528PyInstaller\u7b49\u5de5\u5177\u6253\u5305\u7684EXE\u6587\u4ef6\u662f\u72ec\u7acb\u7684\uff0c\u91cc\u9762\u5305\u542b\u4e86Python\u89e3\u91ca\u5668\u53ca\u6240\u6709\u5fc5\u8981\u7684\u5e93\u548c\u4f9d\u8d56\u9879\u3002\u56e0\u6b64\uff0c\u7528\u6237\u5728\u8fd0\u884c\u8be5EXE\u6587\u4ef6\u65f6\u65e0\u9700\u5b89\u88c5Python\u73af\u5883\u3002\u8fd9\u4f7f\u5f97\u5206\u53d1\u548c\u4f7f\u7528\u53d8\u5f97\u66f4\u52a0\u65b9\u4fbf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u521b\u5efa\u4e00\u4e2aPython\u7684exe\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u8bf8\u5982PyInstaller\u3001cx_Freeze\u3001py2exe\u7b49\u5de5 [&hellip;]","protected":false},"author":3,"featured_media":1119975,"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\/1119957"}],"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=1119957"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1119957\/revisions"}],"predecessor-version":[{"id":1119980,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1119957\/revisions\/1119980"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1119975"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1119957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1119957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1119957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}