{"id":1133,"date":"2019-10-31T10:54:27","date_gmt":"2019-10-31T02:54:27","guid":{"rendered":"http:\/\/www.yumefx.com\/?p=1133"},"modified":"2022-03-23T11:42:49","modified_gmt":"2022-03-23T03:42:49","slug":"pyinstaller-py%e8%84%9a%e6%9c%ac%e6%89%93%e5%8c%85%e6%88%90exe","status":"publish","type":"post","link":"https:\/\/www.yumefx.com\/?p=1133","title":{"rendered":"pyinstaller\u2014py\u811a\u672c\u6253\u5305\u6210exe"},"content":{"rendered":"\n<p>PyInstaller\u662f\u4e00\u4e2a\u5341\u5206\u6709\u7528\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u901a\u8fc7\u5c06py\u6587\u4ef6\u6253\u5305\uff0cPython\u7a0b\u5e8f\u53ef\u4ee5\u5728\u6ca1\u6709\u5b89\u88c5 Python\u7684\u73af\u5883\u4e2d\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u72ec\u7acb\u6587\u4ef6\u65b9\u4fbf\u4f20\u9012\u548c\u7ba1\u7406\u3002<\/p>\n<h1>&nbsp;<\/h1>\n<h1 style=\"text-align: center;\">\u5b89\u88c5\u65b9\u6cd5<\/h1>\n\n\n\n<pre><span>pip install PyInstaller<\/span>\n<\/pre>\n\n\n\n<p>\u6216\u8005<a href=\"http:\/\/www.pyinstaller.org\/\">\u5b98\u7f51<\/a>\u4e0b\u8f7d\u5b89\u88c5\u3002<\/p>\n<h1>\u00a0<\/h1>\n<h1 style=\"text-align: center;\">\u4f7f\u7528<\/h1>\n<h3>\u4f7f\u7528\u4e0b\u8f7d\u5b89\u88c5\u7684\u65b9\u5f0f\u5b89\u88c5\u7684Pyinstaller\u6253\u5305\u65b9\u5f0f<\/h3>\n<p>\u5c06\u9700\u8981\u6253\u5305\u7684\u6587\u4ef6\u653e\u5728\u89e3\u538b\u5f97\u5230\u7684Pyinstaller\u6587\u4ef6\u5939\u4e2d\uff0c\u6253\u5f00cmd\u7a97\u53e3\uff0c\u628a\u8def\u5f84cd\u5230\u5f53\u524d\u8def\u5f84\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u884c\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff08\u6700\u540e\u7684\u662f\u8981\u6253\u5305\u7684py\u6587\u4ef6\uff09\uff1a<\/p>\n\n\n\n<pre><span>python pyinstaller.py -F myfile.py<\/span>\n<\/pre>\n\n\n\n<h3>&nbsp;<\/h3>\n<h3>\u4f7f\u7528pip\u65b9\u5f0f\u5b89\u88c5\u7684Pyinstaller\u6253\u5305\u65b9\u5f0f<\/h3>\n<p>\u6253\u5f00cmd\u7a97\u53e3\uff0ccd\u5207\u6362\u5230\u6587\u4ef6\u6240\u5728\u8def\u5f84\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff08\u6700\u540e\u7684\u662f\u8981\u6253\u5305\u7684py\u6587\u4ef6\uff09\uff1a<\/p>\n\n\n\n<pre><span>pyinstaller -F myfile.py<\/span>\n<\/pre>\n\n\n\n<h1>\u00a0<\/h1>\n<h1 style=\"text-align: center;\">\u53c2\u6570<\/h1>\n<ul>\n<li>-F\/&#8211;onfile\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u8868\u793a\u751f\u6210\u5355\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/li>\n<li>-D\/&#8211;onedir\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u8868\u793a\u751f\u6210\u4e00\u4e2a\u7a0b\u5e8f\u6587\u4ef6\u5939\u3002<\/li>\n<li>-c\/&#8211;console\u00a0 \u00a0 \u00a0 \u00a0 \u8868\u793a\u8fd0\u884c\u65f6\u663e\u793a\u63a7\u5236\u53f0\u7a97\u53e3\uff0c\u9ed8\u8ba4\u53c2\u6570\u4e0d\u9700\u8981\u52a0\u3002<\/li>\n<li>-w\/&#8211;windowed\u00a0 \u00a0\u8868\u793a\u53bb\u6389\u63a7\u5236\u53f0\u7a97\u53e3\uff0c\u8fd9\u5728GUI\u754c\u9762\u65f6\u975e\u5e38\u6709\u7528\uff0c\u5982\u679c\u662f\u547d\u4ee4\u884c\u7a0b\u5e8f\u7684\u8bdd\u4e0d\u8981\u52a0\u8fd9\u4e2a\u9009\u9879\u3002<\/li>\n<li>-p \u8868\u793a\u81ea\u5df1\u81ea\u5b9a\u4e49\u9700\u8981\u52a0\u8f7d\u7684\u7c7b\u8def\u5f84\uff0c\u9632\u6b62\u6709\u5e93\u627e\u4e0d\u5230\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u7528\u4e0d\u5230\u3002<\/li>\n<li>-n\/&#8211;name\u00a0 \u00a0 \u00a0 \u00a0\u6253\u5305\u597d\u7684\u5165\u53e3\u7a0b\u5e8f\u7684\u540d\u79f0\u3002<\/li>\n<li>-y\/&#8211;noconfirm\u00a0 \u00a0 \u65e0\u9700\u786e\u8ba4\u5373\u53ef\u8986\u76d6\u8f93\u51fa\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002<\/li>\n<li>&#8211;distpath\u00a0 \u00a0 \u00a0 \u00a0 \u8f93\u51fa\u8def\u5f84\uff0c\u6253\u5305\u597d\u7684\u7a0b\u5e8f\u7684\u5b58\u653e\u8def\u5f84\uff0c\u9ed8\u8ba4\u4e3a\/dist\u3002<\/li>\n<li>&#8211;workpath\u00a0 \u00a0 \u00a0 \u5de5\u4f5c\u8def\u5f84\uff0c\u7528\u4e8e\u5b58\u653e\u6253\u5305\u8fc7\u7a0b\u4e2d\u7684\u4e34\u65f6\u6587\u4ef6\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u8def\u5f84\u3002<\/li>\n<li>-i\/&#8211;icon\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u6253\u5305\u597d\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u56fe\u6807\u3002<\/li>\n<li>&#8211;key\u00a0 \u00a0 \u7528\u4e8e\u52a0\u5bc6Python\u5b57\u8282\u7801\u7684\u5bc6\u94a5\uff0c\u6b64\u529f\u80fd\u5728\u5185\u90e8\u4f7f\u7528tinyaes\u6a21\u5757\u8fdb\u884c\u52a0\u5bc6\uff0c\u4e0d\u80fd\u4e0eVmProtect\u7b49\u52a0\u58f3\u5de5\u5177\u4e00\u8d77\u4f7f\u7528\u3002<\/li>\n<li>&#8211;clean\u00a0 \u00a0 \u00a0\u6253\u5305\u524d\u6e05\u7406\u7f13\u5b58\u548c\u4e34\u65f6\u6587\u4ef6<\/li>\n<li>&#8211;add-data=&#8221;image.png:img&#8221;\u00a0 \u00a0 \u00a0 \u00a0\u989d\u5916\u9700\u8981\u6253\u5305\u8fdb\u53bb\u7684\u6587\u4ef6\uff0c\u4f8b\u5982\u56fe\u7247\u3001\u6587\u6863\u7b49\u3002<\/li>\n<li>&#8211;add-binary=&#8221;libfo.so:lib&#8221;\u00a0 \u00a0 \u989d\u5916\u9700\u8981\u6253\u5305\u8fdb\u53bb\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u4f8b\u5982dll\u7b49\u3002<\/li>\n<li>&#8211;uac-admin\u00a0 \u00a0 \u00a0 \u6253\u5305\u597d\u7684\u7a0b\u5e8f\u6267\u884c\u65f6\u4f1a\u8981\u6c42\u7ba1\u7406\u5458\u6743\u9650\u3002<\/li>\n<\/ul>\n<h1>\u00a0<\/h1>\n<h1 style=\"text-align: center;\">\u6ce8\u610f\u4e8b\u9879<\/h1>\n<p>\u5373\u4f7f\u5c06py\u811a\u672c\u6253\u5305\u6210exe\u7a0b\u5e8f\uff0c\u4e5f\u4e0d\u610f\u5473\u7740\u4ee3\u7801\u7684\u5b89\u5168\u6027\u5f88\u9ad8\uff0c\u4f8b\u5982\u53ef\u4ee5\u901a\u8fc7<a href=\"https:\/\/github.com\/extremecoders-re\/pyinstxtractor\">pyinstxtractor<\/a>\u8fdb\u884c\u63d0\u53d6\u548c<a href=\"https:\/\/github.com\/rocky\/python-uncompyle6\/\">Uncompyle6<\/a>\u8fdb\u884c\u53cd\u7f16\u8bd1\uff0c\u56e0\u6b64\u8981\u60f3\u6709\u6548\u4fdd\u8bc1\u4ee3\u7801\u5b89\u5168\uff0c\u8fd8\u5f97\u8003\u8651\u6df7\u6dc6\u548c\u52a0\u58f3\u7b49\u624b\u6bb5\u3002<\/p>\n<p>\u53e6\u5916\u6ce8\u610f\u7684\u662f\uff0c\u6253\u5305\u51fa\u7684exe\u53ef\u6267\u884c\u6587\u4ef6\u6216\u8005\u7a0b\u5e8f\u5305\u4f53\u79ef\u4f1a\u504f\u5927\uff0c\u4e3a\u964d\u4f4e\u4f53\u79ef\u53ef\u4ee5\u5728\u7f16\u5199\u7a0b\u5e8f\u65f6\u5c3d\u91cf\u4e0d\u8981\u5bfc\u5165\u7528\u4e0d\u5230\u7684\u5e93\uff0c\u9700\u8981\u7684\u5e93\u7528\u5230\u4ec0\u4e48\u529f\u80fd\u5c31\u53ea\u5bfc\u5165\u4ec0\u4e48\u529f\u80fd\u3002\u4e5f\u5c31\u662f\u8bf4\u5c3d\u91cf\u4e0d\u8981\u7528import XX\u800c\u662f\u7528from XX import YY\u3002<\/p>\n<p>\u6253\u5305\u51fa\u7684\u7a0b\u5e8f\u5982\u679c\u5728\u8fd0\u884c\u65f6\u95ea\u9000\uff0c\u5982\u679c\u786e\u8ba4\u7a0b\u5e8f\u672c\u8eab\u6ca1\u95ee\u9898\uff0c\u90a3\u4e48\u53ef\u80fd\u662f\u7cfb\u7edf\u7f3a\u5c11C++\u6216\u8005.net framework\u7b49\u8fd0\u884c\u5e93\u3002<\/p>\n<h1>\u00a0<\/h1>\n<h1 style=\"text-align: center;\">\u5173\u4e8e\u6253\u5305\u592a\u591a\u5e93\u7684\u4f18\u5316<\/h1>\n<p>\u7531\u4e8e\u6211\u7528\u7684anaconda\u5305\u7ba1\u7406\uff0c\u56e0\u6b64\u4e0d\u53ef\u907f\u514d\u4f1a\u5728\u6253\u5305\u65f6\u6253\u5305\u8fdb\u65e0\u5173\u7684\u5e93\uff0c\u5bfc\u81f4\u7a0b\u5e8f\u5305\u4f53\u79ef\u53d8\u5927\uff0c\u56e0\u6b64\u4e0b\u9762\u8bf4\u4e00\u4e0b\u4f18\u5316\u65b9\u6cd5\u3002<\/p>\n<ul>\n<li>\u4f7f\u7528pycharm\u7b49IDE\u7684venv\u529f\u80fd\uff0c\u5728\u5168\u65b0\u7684Python\u865a\u62df\u73af\u5883\u4e2d\u53ea\u5b89\u88c5\u81ea\u5df1\u7528\u5230\u7684\u5e93\u548cpyinstaller\uff0c\u5e76\u5728\u8fd9\u4e2a\u865a\u62df\u73af\u5883\u4e2d\u6253\u5305\u3002<\/li>\n<li>\u4f7f\u7528pipenv\u5b89\u88c5\u865a\u62df\u73af\u5883\u548c\u7b2c\u4e09\u65b9\u5e93\uff0c\u518d\u8fdb\u884c\u6253\u5305\uff0c\u5177\u4f53\u5982\u4e0b\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u7531\u4e8e\u53ea\u80fd\u6253\u5305\u6210exe\uff0c\u56e0\u6b64\u53ea\u80fd\u5728windows\u73af\u5883\u4e0b\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u53e6\u5916\u6ce8\u610f\u7684\u662f\uff0c\u6253\u5305\u51fa\u7684exe\u53ef\u6267\u884c\u6587\u4ef6\u6216\u8005\u7a0b\u5e8f\u5305\u4f53\u79ef\u4f1a\u504f\u5927\uff0c\u4e3a\u964d\u4f4e\u4f53\u79ef\u53ef\u4ee5\u5728\u7f16\u5199\u7a0b\u5e8f\u65f6\u5c3d\u91cf\u4e0d\u8981\u5bfc\u5165\u7528\u4e0d\u5230\u7684\u5e93\uff0c\u9700\u8981\u7684\u5e93\u7528\u5230\u4ec0\u4e48\u529f\u80fd\u5c31\u53ea\u5bfc\u5165\u4ec0\u4e48\u529f\u80fd\u3002\u4e5f\u5c31\u662f\u8bf4\u5c3d\u91cf\u4e0d\u8981\u7528import XX\u800c\u662f\u7528from XX import YY\u3002<\/p>\n\n\n\n<pre><span>pip install pipenv             #\u5b89\u88c5<\/span>\n<span>pipenv install --python 3.7    #\u9009\u62e9Python\u7248\u672c<\/span>\n<span>pipenv shell                   #\u8fdb\u5165\u65b0\u5efa\u7684\u865a\u62df\u73af\u5883<\/span>\n<span>pip list                       #\u5c55\u793a\u5df2\u5b89\u88c5\u7684\u5e93\uff0c\u5e94\u8be5\u53ea\u6709\u51e0\u4e2a\u81ea\u5e26\u7684\u5e93<\/span>\n<span>pipenv install pyqt5           #\u5b89\u88c5\u7528\u5230\u7684\u5e93<\/span>\n<\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u4e24\u4e2a\u65b9\u6cd5\u90fd\u662f\u901a\u8fc7\u865a\u62df\u4e00\u4e2a\u5e72\u51c0\u7684Python\u73af\u5883\u6253\u5305\uff0c\u4f46\u6709\u65f6\u4f1a\u9047\u5230\u4f7f\u7528\u7684\u5e93\u6709\u5f88\u591a\u4f9d\u8d56\u5e93\u9020\u6210\u6253\u5305\u4f53\u79ef\u504f\u5927\uff0c\u4e0b\u9762\u4e24\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u8fdb\u884c\u5c1d\u8bd5\u3002<\/p>\n<ul>\n<li>\u5982\u679c\u53ea\u7528\u5230\u4e86\u4e00\u4e2a\u5e93\u91cc\u7684\u4e2a\u522b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5c06\u8be5\u6bb5\u4ee3\u7801\u76f4\u63a5\u590d\u5236\u5230\u81ea\u5df1\u811a\u672c\u4e0a\uff0c\u5f53\u6210\u81ea\u5df1\u5199\u7684\u65b9\u6cd5\u8fdb\u884c\u8c03\u7528\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\u590d\u5236\u8fc7\u6765\u7684\u4ee3\u7801\u4e2d\u6709\u6ca1\u6709\u5176\u4ed6\u5f15\u7528\uff0c\u6709\u7684\u8bdd\u8981\u4e00\u5e76\u590d\u5236\u8fc7\u6765\u3002<\/li>\n<li>\u5982\u679c\u4ee5\u4e0a\u65b9\u6cd5\u90fd\u4e0d\u7ba1\u7528\uff0c\u90a3\u8fd8\u6709\u6700\u540e\u4e00\u4e2a\u7b28\u65b9\u6cd5\uff0c\u76f4\u63a5\u5220\u3002\u6bd4\u5982\u8bf4\u6211\u7528\u5230\u4e86pandas\u5e93\u8bfb\u53d6csv\u6587\u4ef6\u7684\u529f\u80fd\uff0c\u5b83\u4f1a\u628anumpy\u7b49\u4f9d\u8d56\u5e93\u4e00\u5e76\u6253\u5305\uff0c\u6253\u5305\u540e\u6587\u4ef6\u5305\u5927\u5c0f\u8d85\u8fc7\u4e86700M\u3002<\/li>\n<\/ul>\n<p>\u7ecf\u8fc7\u5220\u9664\u67d0\u4e9bdll\u6587\u4ef6\u5e76\u8fd0\u884c\u6d4b\u8bd5\uff0c\u5728\u5220\u9664\u6389\u4e00\u4e9b\u786e\u5b9e\u7528\u4e0d\u5230\u7684\u6587\u4ef6\u540e\uff0c\u6253\u5305\u540e\u7684\u6587\u4ef6\u5305\u964d\u5230\u4e86100M\uff0c\u5f53\u7136\u8fd9\u4e2a\u65b9\u6cd5\u8981\u4ed4\u7ec6\u6d4b\u8bd5\uff0c\u907f\u514d\u5220\u6389\u4e86\u5fc5\u8981\u7684dll\u5bfc\u81f4\u67d0\u4e9b\u529f\u80fd\u5931\u6548\u3002<\/p>\n<p>&nbsp;<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6210\u957f\u5c31\u662f\u59a5\u534f\u4e0e\u575a\u6301\u7684\u4e24\u96be\u3002<\/p>\n<p style=\"text-align: right;\">\u300a\u89e3\u5fe7\u6742\u8d27\u5e97\u300b<br \/>\u2014\u2014\u4e1c\u91ce\u572d\u543e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PyInstaller\u662f\u4e00\u4e2a\u5341\u5206\u6709\u7528\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u901a\u8fc7\u5c06py\u6587\u4ef6\u6253\u5305\uff0cPython\u7a0b\u5e8f\u53ef\u4ee5\u5728\u6ca1\u6709\u5b89\u88c5 Pytho [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1134,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,4],"tags":[37,14,25],"_links":{"self":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts\/1133"}],"collection":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1133"}],"version-history":[{"count":0,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts\/1133\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/media\/1134"}],"wp:attachment":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}