{"id":1020960,"date":"2024-12-27T13:17:36","date_gmt":"2024-12-27T05:17:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1020960.html"},"modified":"2024-12-27T13:17:38","modified_gmt":"2024-12-27T05:17:38","slug":"%e6%a0%91%e8%8e%93%e6%b4%bepython%e5%a6%82%e4%bd%95%e6%89%93%e5%8c%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1020960.html","title":{"rendered":"\u6811\u8393\u6d3epython\u5982\u4f55\u6253\u5305"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25163318\/881f83cc-b3e4-41e9-a44b-3e1a865b25b4.webp\" alt=\"\u6811\u8393\u6d3epython\u5982\u4f55\u6253\u5305\" \/><\/p>\n<p><p> \u5728\u4f7f\u7528\u6811\u8393\u6d3e\u8fdb\u884cPython\u9879\u76ee\u5f00\u53d1\u65f6\uff0c<strong>\u6253\u5305Python\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u63d0\u9ad8\u9879\u76ee\u7684\u53ef\u79fb\u690d\u6027\u3001\u7b80\u5316\u90e8\u7f72\u8fc7\u7a0b\u3001\u786e\u4fdd\u73af\u5883\u4e00\u81f4\u6027<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528<code>PyInstaller<\/code>\u3001<code>cx_Freeze<\/code>\u6216<code>setuptools<\/code>\u7b49\u5de5\u5177\u6765\u521b\u5efa\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u63a8\u8350\u4f7f\u7528<code>PyInstaller<\/code>\uff0c\u56e0\u4e3a\u5b83\u652f\u6301\u5927\u591a\u6570Python\u5e94\u7528\u7a0b\u5e8f\u5e76\u4e14\u6613\u4e8e\u4f7f\u7528\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728\u6811\u8393\u6d3e\u4e0a\u4f7f\u7528<code>PyInstaller<\/code>\u6765\u6253\u5305Python\u9879\u76ee\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5\u548c\u914d\u7f6e\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u6253\u5305\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u6811\u8393\u6d3e\u4e0a\u7684Python\u73af\u5883\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u548c\u914d\u7f6e\u3002\u901a\u5e38\uff0c\u6811\u8393\u6d3e\u81ea\u5e26Python\uff0c\u4f46\u5982\u679c\u9700\u8981\u7279\u5b9a\u7248\u672c\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pyenv<\/code>\u6765\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002\u6b64\u5916\uff0c\u8fd8\u9700\u5b89\u88c5\u76f8\u5173\u7684\u5305\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h4>1.1 \u5b89\u88c5Python\u548cpip<\/h4>\n<\/p>\n<p><p>\u786e\u4fdd\u6811\u8393\u6d3e\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u548cpip\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p>pip3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update<\/p>\n<p>sudo apt install python3 python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.2 \u5b89\u88c5PyInstaller<\/h4>\n<\/p>\n<p><p><code>PyInstaller<\/code>\u662f\u4e00\u4e2a\u7528\u4e8e\u5c06Python\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u72ec\u7acb\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5de5\u5177\u3002\u53ef\u4ee5\u901a\u8fc7pip\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 install pyinstaller<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528PyInstaller\u6253\u5305Python\u9879\u76ee<\/h3>\n<\/p>\n<p><h4>2.1 \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Python\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Python\u9879\u76ee\u7528\u4e8e\u6f14\u793a\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>app.py<\/code>\u7684\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># app.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, Raspberry Pi!&quot;)<\/p>\n<p>if __name__ == &quot;__main__&quot;:<\/p>\n<p>    main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2 \u4f7f\u7528PyInstaller\u8fdb\u884c\u6253\u5305<\/h4>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u5230\u9879\u76ee\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 app.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6761\u547d\u4ee4\u4f1a\u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5c06\u6240\u6709\u4f9d\u8d56\u6253\u5305\u5728\u4e00\u8d77\u3002<code>--onefile<\/code>\u9009\u9879\u8868\u793a\u751f\u6210\u5355\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>2.3 \u7406\u89e3PyInstaller\u751f\u6210\u7684\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u6253\u5305\u5b8c\u6210\u540e\uff0cPyInstaller\u4f1a\u751f\u6210\u4e00\u4e2a<code>dist<\/code>\u76ee\u5f55\uff0c\u91cc\u9762\u5305\u542b\u4e86\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5728Linux\u7cfb\u7edf\u4e0a\uff0c\u751f\u6210\u7684\u6587\u4ef6\u6ca1\u6709\u540e\u7f00\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/dist\/app<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u53ef\u4ee5\u6b63\u5e38\u8f93\u51fa\u201cHello, Raspberry Pi!\u201d\uff0c\u5219\u8bf4\u660e\u6253\u5305\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5904\u7406\u6253\u5305\u8fc7\u7a0b\u4e2d\u7684\u5e38\u89c1\u95ee\u9898<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528PyInstaller\u6253\u5305\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u5982\u7f3a\u5c11\u6a21\u5757\u3001\u8def\u5f84\u95ee\u9898\u548c\u8d44\u6e90\u6587\u4ef6\u672a\u5305\u542b\u7b49\u3002<\/p>\n<\/p>\n<p><h4>3.1 \u7f3a\u5c11\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u5728\u8fd0\u884c\u6253\u5305\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u65f6\uff0c\u63d0\u793a\u7f3a\u5c11\u6a21\u5757\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u89e3\u51b3\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u68c0\u67e5<code>requirements.txt<\/code>\u6587\u4ef6\uff0c\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u5305\u90fd\u5df2\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528<code>--hidden-import<\/code>\u9009\u9879\u663e\u5f0f\u6307\u5b9a\u7f3a\u5c11\u7684\u6a21\u5757\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller --onefile --hidden-import=missing_module app.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>3.2 \u8d44\u6e90\u6587\u4ef6\u672a\u5305\u542b<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u4f9d\u8d56\u4e8e\u67d0\u4e9b\u975ePython\u6587\u4ef6\uff08\u5982\u914d\u7f6e\u6587\u4ef6\u3001\u56fe\u50cf\u7b49\uff09\uff0c\u9700\u8981\u786e\u4fdd\u8fd9\u4e9b\u6587\u4ef6\u5728\u6253\u5305\u65f6\u88ab\u5305\u542b\u3002\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>.spec<\/code>\u6587\u4ef6\u6765\u6dfb\u52a0\u8d44\u6e90\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u6709\u4e00\u4e2a<code>config.json<\/code>\u6587\u4ef6\u9700\u8981\u5305\u542b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># app.spec<\/p>\n<p>a = Analysis([&#39;app.py&#39;],<\/p>\n<p>             datas=[(&#39;config.json&#39;, &#39;.&#39;)],<\/p>\n<p>             ...<\/p>\n<p>             )<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u91cd\u65b0\u8fd0\u884c<code>PyInstaller<\/code>\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyinstaller app.spec<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u4f18\u5316\u6253\u5305\u548c\u90e8\u7f72<\/h3>\n<\/p>\n<p><p>\u5728\u6210\u529f\u6253\u5305\u4e4b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u4f18\u5316\u63aa\u65bd\u6765\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u90e8\u7f72\u7684\u4fbf\u6377\u6027\u3002<\/p>\n<\/p>\n<p><h4>4.1 \u4f7f\u7528\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u5728\u6253\u5305\u4e4b\u524d\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5168\u5c40\u5305\u7684\u51b2\u7a81\uff0c\u5e76\u786e\u4fdd\u6253\u5305\u65f6\u7684\u4f9d\u8d56\u73af\u5883\u662f\u4e00\u81f4\u7684\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv venv<\/p>\n<p>source venv\/bin\/activate<\/p>\n<p>pip install -r requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528\u865a\u62df\u73af\u5883\u540e\uff0c\u518d\u8fd0\u884c<code>PyInstaller<\/code>\u8fdb\u884c\u6253\u5305\u3002<\/p>\n<\/p>\n<p><h4>4.2 \u81ea\u52a8\u5316\u90e8\u7f72\u811a\u672c<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u7b80\u5316\u90e8\u7f72\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2aShell\u811a\u672c\u6765\u81ea\u52a8\u5316\u6253\u5305\u548c\u90e8\u7f72\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">#!\/bin\/bash<\/p>\n<h2><strong>build.sh<\/strong><\/h2>\n<h2><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong><\/h2>\n<p>source venv\/bin\/activate<\/p>\n<h2><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong><\/h2>\n<p>pip install -r requirements.txt<\/p>\n<h2><strong>\u6253\u5305<\/strong><\/h2>\n<p>pyinstaller --onefile app.py<\/p>\n<h2><strong>\u590d\u5236\u5230\u76ee\u6807\u76ee\u5f55<\/strong><\/h2>\n<p>cp dist\/app \/path\/to\/deploy\/directory<\/p>\n<p>echo &quot;Deployment completed.&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd0\u884c\u8fd9\u4e2a\u811a\u672c\u53ef\u4ee5\u81ea\u52a8\u5b8c\u6210\u6253\u5305\u548c\u590d\u5236\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u63a2\u7d22\u5176\u4ed6\u6253\u5305\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u9664\u4e86PyInstaller\uff0c\u5176\u4ed6\u5982<code>cx_Freeze<\/code>\u548c<code>setuptools<\/code>\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6253\u5305Python\u9879\u76ee\u3002\u6bcf\u79cd\u5de5\u5177\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\uff0c\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h4>5.1 cx_Freeze<\/h4>\n<\/p>\n<p><p><code>cx_Freeze<\/code>\u662f\u53e6\u4e00\u4e2a\u5e38\u7528\u7684Python\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u5de5\u5177\uff0c\u652f\u6301Windows\u548cLinux\u5e73\u53f0\u3002\u5b83\u7684\u4f7f\u7528\u65b9\u6cd5\u4e0ePyInstaller\u7c7b\u4f3c\uff0c\u4f46\u53ef\u80fd\u9700\u8981\u624b\u52a8\u8c03\u6574\u4e00\u4e9b\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5<code>cx_Freeze<\/code>\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>\u521b\u5efa\u4e00\u4e2a<code>setup.py<\/code>\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># setup.py<\/p>\n<p>from cx_Freeze import setup, Executable<\/p>\n<p>setup(<\/p>\n<p>    name=&quot;app&quot;,<\/p>\n<p>    version=&quot;0.1&quot;,<\/p>\n<p>    description=&quot;My application&quot;,<\/p>\n<p>    executables=[Executable(&quot;app.py&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<p><p>\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f4d\u4e8e<code>build<\/code>\u76ee\u5f55\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>5.2 setuptools<\/h4>\n<\/p>\n<p><p><code>setuptools<\/code>\u4e3b\u8981\u7528\u4e8e\u7ba1\u7406Python\u5305\u7684\u5206\u53d1\u548c\u5b89\u88c5\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u53d1\u5e03\u5230PyPI\u65f6\u3002<\/p>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a<code>setup.py<\/code>\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># setup.py<\/p>\n<p>from setuptools import setup<\/p>\n<p>setup(<\/p>\n<p>    name=&quot;app&quot;,<\/p>\n<p>    version=&quot;0.1&quot;,<\/p>\n<p>    py_modules=[&quot;app&quot;],<\/p>\n<p>    entry_points={<\/p>\n<p>        &#39;console_scripts&#39;: [<\/p>\n<p>            &#39;app=app:main&#39;,<\/p>\n<p>        ],<\/p>\n<p>    },<\/p>\n<p>)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u53ef\u5206\u53d1\u7684\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py sdist bdist_wheel<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u751f\u6210\u7684\u6587\u4ef6\u4f4d\u4e8e<code>dist<\/code>\u76ee\u5f55\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728\u6811\u8393\u6d3e\u4e0a\u6253\u5305Python\u5e94\u7528\u7a0b\u5e8f\uff0c\u901a\u8fc7\u5de5\u5177\u5982<code>PyInstaller<\/code>\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u9ad8\u9879\u76ee\u7684\u53ef\u79fb\u690d\u6027\u548c\u90e8\u7f72\u6548\u7387\u3002<strong>\u9009\u62e9\u5408\u9002\u7684\u6253\u5305\u5de5\u5177\u3001\u6b63\u786e\u914d\u7f6e\u73af\u5883\u3001\u5904\u7406\u4f9d\u8d56\u548c\u8d44\u6e90\u6587\u4ef6\u3001\u4f18\u5316\u6253\u5305\u8fc7\u7a0b<\/strong>\uff0c\u8fd9\u4e9b\u90fd\u662f\u786e\u4fdd\u6210\u529f\u6253\u5305\u548c\u90e8\u7f72\u7684\u5173\u952e\u6b65\u9aa4\u3002\u901a\u8fc7\u4e0d\u65ad\u63a2\u7d22\u548c\u5b9e\u8df5\uff0c\u53ef\u4ee5\u627e\u5230\u6700\u9002\u5408\u81ea\u5df1\u9879\u76ee\u7684\u6253\u5305\u548c\u90e8\u7f72\u65b9\u6848\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u6811\u8393\u6d3e\u4e0a\u6253\u5305Python\u5e94\u7528\u7a0b\u5e8f\uff1f<\/strong><br \/>\u5728\u6811\u8393\u6d3e\u4e0a\u6253\u5305Python\u5e94\u7528\u7a0b\u5e8f\u901a\u5e38\u6d89\u53ca\u5c06\u7a0b\u5e8f\u53ca\u5176\u4f9d\u8d56\u9879\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u4ee5\u4fbf\u4e8e\u5206\u53d1\u548c\u5b89\u88c5\u3002\u5e38\u7528\u7684\u6253\u5305\u5de5\u5177\u5305\u62ecPyInstaller\u548ccx_Freeze\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u786e\u4fdd\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u8fd0\u884c\u65f6\u4e0d\u4f9d\u8d56\u4e8ePython\u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>\u6253\u5305Python\u5e94\u7528\u7a0b\u5e8f\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4e8b\u9879\uff1f<\/strong><br \/>\u5728\u6253\u5305\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u5e93\u90fd\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u5e76\u5728\u6253\u5305\u914d\u7f6e\u6587\u4ef6\u4e2d\u5217\u51fa\u3002\u6b64\u5916\uff0c\u8003\u8651\u5230\u6811\u8393\u6d3e\u7684\u786c\u4ef6\u8d44\u6e90\uff0c\u4f18\u5316\u4ee3\u7801\u4ee5\u51cf\u5c11\u5e94\u7528\u7a0b\u5e8f\u7684\u4f53\u79ef\u548c\u5185\u5b58\u5360\u7528\u4e5f\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<p><strong>\u6709\u6ca1\u6709\u63a8\u8350\u7684\u6253\u5305\u5de5\u5177\u548c\u6b65\u9aa4\uff1f<\/strong><br \/>\u5bf9\u4e8e\u6811\u8393\u6d3e\uff0cPyInstaller\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u9009\u62e9\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u6253\u5305\uff1a\u9996\u5148\uff0c\u5b89\u88c5PyInstaller\uff08\u4f7f\u7528pip install pyinstaller\uff09\uff0c\u63a5\u7740\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u8fd0\u884cpyinstaller your_script.py\uff0c\u6700\u540e\u5728dist\u6587\u4ef6\u5939\u4e2d\u627e\u5230\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u786e\u4fdd\u5728\u6811\u8393\u6d3e\u4e0a\u8fdb\u884c\u6d4b\u8bd5\u4ee5\u786e\u8ba4\u5e94\u7528\u7a0b\u5e8f\u7684\u517c\u5bb9\u6027\u548c\u6027\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728\u4f7f\u7528\u6811\u8393\u6d3e\u8fdb\u884cPython\u9879\u76ee\u5f00\u53d1\u65f6\uff0c\u6253\u5305Python\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u63d0\u9ad8\u9879\u76ee\u7684\u53ef\u79fb\u690d\u6027\u3001\u7b80\u5316\u90e8\u7f72\u8fc7\u7a0b\u3001\u786e\u4fdd\u73af\u5883 [&hellip;]","protected":false},"author":3,"featured_media":1020966,"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\/1020960"}],"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=1020960"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1020960\/revisions"}],"predecessor-version":[{"id":1020969,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1020960\/revisions\/1020969"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1020966"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1020960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1020960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1020960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}