{"id":10182,"date":"2023-11-28T15:44:29","date_gmt":"2023-11-28T07:44:29","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=10182"},"modified":"2023-11-28T15:44:29","modified_gmt":"2023-11-28T07:44:29","slug":"pipenv%e6%89%93%e5%8c%85exe%e6%93%8d%e4%bd%9c%e6%b5%81%e7%a8%8b%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/10182\/","title":{"rendered":"pipenv\u6253\u5305exe\u64cd\u4f5c\u6d41\u7a0b\u4ecb\u7ecd"},"content":{"rendered":"

pipenv\u662f\u4e00\u4e2aPython\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406Python\u5305\u548c\u4f9d\u8d56\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u5e38\u5e38\u9700\u8981\u5c06\u6211\u4eec\u7684Pytholinux\u8f6f\u4ef6\u8bba\u575b<\/a>n\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u65b9\u5982\u4f55\u505a\u4e00\u4e2aexe\u7a0b\u5e8f<\/a>\u4fbf\u5728\u5176\u4ed6\u673a\u5668\u4e0a\u8fd0\u884c\u3002pipenv\u63d0\u4f9b\u4e86\u4e00\u79cd\u975e\u5e38\u7b80\u5355\u7684\u65b9\u5f0f\u6765\u6253\u5305Python\u7a0b\u5e8f\u6210exe\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

\u6253\u5305exe\u7684\u539f\u7406\u662f\u5c06Python\u7a0b\u5e8f\u8f6c\u6362\u6210\u673a\u5668\u7801\uff0c\u4f7f\u5f97\u7a0b\u5e8f\u53ef\u4ee5\u5728\u6ca1\u6709Python\u73af\u5883\u7684\u673a\u5668\u4e0a\u8fd0\u884c\u3002\u6253\u5305exe\u7684\u8fc7\u7a0b\u53ef\u4ee5\u5206\u4e3a\u4e24\u4e2a\u6b65\u9aa4\uff1a\u7b2c\u4e00\u6b65\u662f\u5c06Python\u7a0b\u5e8f\u8f6c\u6362\u6210\u673a\u5668\u7801\uff1b\u7b2c\u4e8c\u6b65\u662f\u5c06\u673a\u5668\u7801\u548cPython\u89e3\u91ca\u5668\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

pipenv\u4f7f\u7528\u4e86PyInstaller\u5de5\u5177\u6765\u5b8c\u6210Python\u7a0b\u5e8f\u7684\u6253\u5305\u3002PyInstaller\u662f\u4e00\u4e2a\u6d41\u884c\u7684Python\u6253\u5305\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210\u5404\u79cd\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5305\u62ecexe\u3001dmg\u3001rpm\u7b49\u3002PyInstaller\u4f1a\u5c06Python\u7a0b\u5e8f\u8f6c\u6362\u6210\u673a\u5668\u7801\uff0c\u5e76\u4e14\u5c06Python\u89e3\u91ca\u5668\u6253\u5305\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002<\/p>\n

\u4e0b\u9762\u662f\u4f7f\u7528pipenv\u6253\u5305Python\u7a0b\u5e8f\u6210exe\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6b65\u9aa4\uff1a<\/p>\n

1. \u5b89\u88c5pipenv<\/p>\n

\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5b89\u88c5pipenv\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n

“`<\/p>\n

<\/figure>\n<\/p>\n

pip install pipenv<\/p>\n

“`<\/p>\n

2. \u521b\u5efa\u865a\u62df\u73af\u5883<\/p>\n

\u4f7f\u7528pipenv\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\uff0c\u8fd9\u6837\u6211\u4eec\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u6211\u4eec\u7684Python\u5305\u548c\u4f9d\u8d56\uff1a<\/p>\n

“`<\/p>\n

pipenv –python 3.8<\/p>\n

“`<\/p>\n

3. \u5b89\u88c5Python\u5305\u548c\u4f9d\u8d56<\/p>\n

\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u6211\u4eec\u9700\u8981\u7684Python\u5305\u548c\u4f9d\u8d56\uff1a<\/p>\n

“`<\/p>\n

pipenv install requests<\/p>\n

“`<\/p>\n

4. \u6253\u5305Python\u7a0b\u5e8f<\/p>\n

\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5305Python\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

pipenv run pyinstaller –onefile myprogram.py<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0cmyprogram.py\u662f\u6211\u4eec\u8981\u6253\u5305\u7684Python\u7a0b\u5e8f\u7684\u6587\u4ef6\u540d\u3002<\/p>\n

PyInstaller\u4f1a\u5c06myprogram.py\u8f6c\u6362\u6210\u673a\u5668\u7801\uff0c\u5e76\u5c06Python\u89e3\u91ca\u5668\u6253\u5305\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002\u6253\u5305\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728dist\u76ee\u5f55\u4e0b\u627e\u5230\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

5. \u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n

\u5c06\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u62f7\u8d1d\u5230\u5176\u4ed6\u673a\u5668\u4e0a\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\uff0c\u65e0\u9700\u5b89\u88c5Python\u73af\u5883\u548c\u4f9d\u8d56\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

pipenv\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u5f0f\u6765\u6253\u5305Python\u7a0b\u5e8f\u6210exe\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4f7f\u7528pipenv\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406Python\u5305\u548c\u4f9d\u8d56\uff0c\u4f7f\u7528PyInstaller\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u8f6c\u6362\u6210\u673a\u5668\u7801\uff0c\u5e76\u5c06Python\u89e3\u91ca\u5668\u6253\u5305\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002\u6253\u5305\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u5176\u4ed6\u673a\u5668\u4e0a\u76f4\u63a5\u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u65e0\u9700\u5b89\u88c5Python\u73af\u5883\u548c\u4f9d\u8d56\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

pipenv\u662f\u4e00\u4e2aPython\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7ba1\u7406Python\u5305\u548c\u4f9d\u8d56\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u5e38\u5e38\u9700\u8981\u5c06\u6211\u4eec\u7684Python\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u65b9\u4fbf\u5728\u5176\u4ed6\u673a\u5668\u4e0a\u8fd0\u884c\u3002pipenv\u63d0\u4f9b<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[3549,256,16138,157,89],"topic":[],"class_list":["post-10182","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-3549","tag-256","tag-exe","tag-157","tag-89"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/10182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=10182"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/10182\/revisions"}],"predecessor-version":[{"id":10251,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/10182\/revisions\/10251"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=10182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=10182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=10182"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=10182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}