{"id":1033,"date":"2024-12-15T11:37:09","date_gmt":"2024-12-15T03:37:09","guid":{"rendered":"http:\/\/www.chan.ink\/?p=1033"},"modified":"2024-12-15T11:37:13","modified_gmt":"2024-12-15T03:37:13","slug":"%e3%80%90uwsgi%e3%80%91%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e5%8f%82%e6%95%b0%e6%b5%85%e6%9e%90","status":"publish","type":"post","link":"http:\/\/www.chan.ink\/index.php\/2024\/12\/15\/%e3%80%90uwsgi%e3%80%91%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e5%8f%82%e6%95%b0%e6%b5%85%e6%9e%90\/","title":{"rendered":"\u3010uwsgi\u3011\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u6d45\u6790"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong><code>PYTHONPATH<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b9a\u4e49<\/strong>: <code>PYTHONPATH<\/code> \u662f\u4e00\u4e2a\u73af\u5883\u53d8\u91cf\uff0c\u5b83\u6307\u5b9a\u4e86 Python \u89e3\u91ca\u5668\u5728\u6267\u884c\u4ee3\u7801\u65f6\u67e5\u627e\u6a21\u5757\u7684\u8def\u5f84\u3002<strong>\u7b80\u5355\u6765\u8bf4\uff0c<code>PYTHONPATH<\/code> \u544a\u8bc9 Python \u89e3\u91ca\u5668\u5728\u54ea\u91cc\u5bfb\u627e\u4f60\u8981\u5bfc\u5165\u7684\u6a21\u5757\u6216\u5305\u3002<\/strong><\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>: \u5728 <code>uWSGI<\/code> \u914d\u7f6e\u4e2d\uff0c<code>PYTHONPATH<\/code> \u901a\u5e38\u7528\u6765\u8bbe\u7f6e\u4e00\u4e2a\u6216\u591a\u4e2a\u76ee\u5f55\uff0c\u786e\u4fdd uWSGI \u8fdb\u7a0b\u80fd\u627e\u5230\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u6216\u8005\u7279\u5b9a\u7684\u5e93\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e0d\u5728\u9ed8\u8ba4\u7684 Python \u73af\u5883\u8def\u5f84\u4e0b\uff0c\u4f60\u9700\u8981\u901a\u8fc7\u8bbe\u7f6e <code>PYTHONPATH<\/code> \u6765\u6307\u5b9a\u4ee3\u7801\u6240\u5728\u7684\u76ee\u5f55\u3002\n<ul class=\"wp-block-list\">\n<li><strong>\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u5e94\u7528\u5728\u67d0\u4e2a\u975e\u6807\u51c6\u8def\u5f84\u4e0b\uff0c\u6216\u8005\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7248\u672c\u7684\u5e93\uff0c\u8bbe\u7f6e <code>PYTHONPATH<\/code> \u53ef\u4ee5\u8ba9 <code>uWSGI<\/code> \u5728\u8fd0\u884c\u65f6\u627e\u5230\u8fd9\u4e9b\u8def\u5f84\u3002<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><code>python<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b9a\u4e49<\/strong>: <code>python<\/code> \u662f\u4e00\u4e2a uWSGI \u914d\u7f6e\u9009\u9879\uff0c\u7528\u4e8e\u6307\u5b9a Python \u89e3\u91ca\u5668\u7684\u8def\u5f84\uff0c\u6216\u8005\u6307\u5b9a Python \u7248\u672c\u7684\u540d\u79f0\u3002<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>: \u5f53\u4f60\u5728 uWSGI \u914d\u7f6e\u4e2d\u4f7f\u7528 <code>python<\/code> \u9009\u9879\u65f6\uff0c\u5b83\u544a\u8bc9 uWSGI \u4f7f\u7528\u54ea\u4e2a Python \u89e3\u91ca\u5668\u6765\u8fd0\u884c\u4f60\u7684\u5e94\u7528\u3002\u4f60\u53ef\u4ee5\u6307\u5b9a\u7cfb\u7edf\u7684 Python \u89e3\u91ca\u5668\u8def\u5f84\uff0c\u6216\u8005\u6307\u5b9a\u865a\u62df\u73af\u5883\u4e2d\u7684\u89e3\u91ca\u5668\u3002\n<ul class=\"wp-block-list\">\n<li>\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u6307\u5b9a\u4f7f\u7528 Python 3.x \u800c\u4e0d\u662f\u9ed8\u8ba4\u7684 Python 2.x\uff0c\u6216\u8005\u4f7f\u7528\u7279\u5b9a\u865a\u62df\u73af\u5883\u4e2d\u7684\u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>PYTHONPATH<\/code><\/strong> \u7528\u4e8e\u6307\u5b9a Python \u67e5\u627e\u6a21\u5757\u7684\u8def\u5f84\uff0c\u786e\u4fdd Python \u80fd\u627e\u5230\u4f60\u7684\u5e94\u7528\u4ee3\u7801\u6216\u8005\u4f9d\u8d56\u5e93\u3002<\/li>\n\n\n\n<li><strong><code>python<\/code><\/strong> \u7528\u4e8e\u6307\u5b9a\u8fd0\u884c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u7684 Python \u89e3\u91ca\u5668\u7684\u8def\u5f84\u6216\u7248\u672c\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e24\u8005\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\uff0c<code>PYTHONPATH<\/code> \u5f71\u54cd\u7684\u662f\u6a21\u5757\u67e5\u627e\u8def\u5f84\uff0c\u800c <code>python<\/code> \u5f71\u54cd\u7684\u662f\u6267\u884c\u65f6\u4f7f\u7528\u7684 Python \u89e3\u91ca\u5668\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><code>virtualenv<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b9a\u4e49<\/strong>: <code>virtualenv<\/code> \u914d\u7f6e\u9009\u9879\u7528\u4e8e\u6307\u5b9a Python \u7684\u865a\u62df\u73af\u5883\u7684\u8def\u5f84\u3002\u901a\u8fc7\u8bbe\u7f6e <code>virtualenv<\/code>\uff0c<code>uWSGI<\/code> \u4f1a\u4f7f\u7528\u8be5\u865a\u62df\u73af\u5883\u4e2d\u7684 Python \u89e3\u91ca\u5668\u548c\u5b89\u88c5\u7684\u5e93\u6765\u8fd0\u884c\u4f60\u7684\u5e94\u7528\u3002<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>: \u5982\u679c\u4f60\u4f7f\u7528\u865a\u62df\u73af\u5883\uff08\u5982\u4f7f\u7528 <code>venv<\/code> \u6216 <code>virtualenv<\/code> \u5de5\u5177\u521b\u5efa\u7684\u73af\u5883\uff09\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e <code>virtualenv<\/code> \u6307\u5b9a uWSGI \u4f7f\u7528\u8be5\u865a\u62df\u73af\u5883\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\u4f60\u7684\u5e94\u7528\u53ef\u4ee5\u72ec\u7acb\u4e8e\u7cfb\u7edf\u7ea7\u7684 Python \u73af\u5883\u8fd0\u884c\uff0c\u907f\u514d\u5e93\u4f9d\u8d56\u51b2\u7a81\uff0c\u5e76\u4e14\u4fbf\u4e8e\u7ba1\u7406\u5e94\u7528\u7684\u4f9d\u8d56\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bf4\u660e<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8bbe\u7f6e\u4e86 <code>virtualenv<\/code> \u540e\uff0c<code>uWSGI<\/code> \u4f1a\u81ea\u52a8\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4f7f\u5f97\u5e94\u7528\u5728\u8fd0\u884c\u65f6\u4f7f\u7528\u865a\u62df\u73af\u5883\u4e2d\u7684 Python \u89e3\u91ca\u5668\u548c\u5df2\u5b89\u88c5\u7684\u5e93\u3002<\/li>\n\n\n\n<li>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c<code>virtualenv<\/code> \u914d\u7f6e\u4e0d\u9700\u8981\u6307\u5b9a <code>python<\/code> \u89e3\u91ca\u5668\uff0c<code>uWSGI<\/code> \u4f1a\u81ea\u52a8\u627e\u5230\u865a\u62df\u73af\u5883\u4e2d\u7684 Python \u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><code>home<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b9a\u4e49<\/strong>: <code>home<\/code> \u914d\u7f6e\u9009\u9879\u4e0e <code>virtualenv<\/code> \u6709\u4e9b\u76f8\u4f3c\uff0c\u4f46 <code>home<\/code> \u662f\u4e00\u4e2a\u66f4\u52a0\u901a\u7528\u7684\u9009\u9879\u3002\u5b83\u544a\u8bc9 <code>uWSGI<\/code> \u4f7f\u7528\u6307\u5b9a\u8def\u5f84\u4f5c\u4e3a Python \u8fd0\u884c\u73af\u5883\uff0c\u901a\u5e38\u7528\u4e8e\u6307\u5b9a\u4e00\u4e2a\u865a\u62df\u73af\u5883\u6216\u7279\u5b9a\u7684 Python \u73af\u5883\u3002<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>: <code>home<\/code> \u9009\u9879\u7528\u6765\u6307\u5b9a Python \u73af\u5883\u7684\u8def\u5f84\uff0c\u901a\u5e38\u7528\u4e8e\u6307\u5b9a\u865a\u62df\u73af\u5883\u7684\u8def\u5f84\uff0c\u4f46\u5b83\u7684\u7528\u9014\u66f4\u5e7f\u6cdb\u3002\u4f60\u53ef\u4ee5\u5c06 <code>home<\/code> \u7528\u4f5c\u8def\u5f84\u6307\u5411\u4e00\u4e2a\u5305\u542b Python \u89e3\u91ca\u5668\u7684\u76ee\u5f55\uff0c\u6bd4\u5982\u865a\u62df\u73af\u5883\u3001\u7cfb\u7edf\u7684 Python \u5b89\u88c5\u76ee\u5f55\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u533a\u522b<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>home<\/code> \u53ef\u4ee5\u7528\u4e8e\u4efb\u4f55 Python \u73af\u5883\uff0c\u5b83\u5e76\u4e0d\u7279\u522b\u5f3a\u8c03\u662f\u865a\u62df\u73af\u5883\u3002\u4f60\u53ef\u4ee5\u5c06\u5176\u7528\u4e8e\u865a\u62df\u73af\u5883\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6307\u5411\u4e00\u4e2a\u7cfb\u7edf\u7ea7\u7684 Python \u73af\u5883\u3002<\/li>\n\n\n\n<li><code>virtualenv<\/code> \u66f4\u52a0\u4e13\u6ce8\u4e8e\u4e3a\u5e94\u7528\u63d0\u4f9b\u4e00\u4e2a\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u5e94\u7528\u4ee3\u7801\u548c\u4f9d\u8d56\u88ab\u5b8c\u5168\u9694\u79bb\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><code>virtualenv<\/code> vs <code>home<\/code><\/strong>\uff1a\u4e3b\u8981\u533a\u522b<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>virtualenv<\/code><\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u4e13\u95e8\u4e3a\u865a\u62df\u73af\u5883\u8bbe\u8ba1\uff0c\u544a\u8bc9 <code>uWSGI<\/code> \u4f7f\u7528\u865a\u62df\u73af\u5883\u4e2d\u7684 Python \u89e3\u91ca\u5668\u548c\u5b89\u88c5\u7684\u4f9d\u8d56\u5e93\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u4f60\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u90e8\u7f72 Python \u5e94\u7528\uff0c\u8fd9\u901a\u5e38\u662f\u66f4\u5e38\u89c1\u7684\u914d\u7f6e\u9009\u9879\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>home<\/code><\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u901a\u7528\u914d\u7f6e\u9009\u9879\uff0c\u6307\u5411\u5305\u542b Python \u89e3\u91ca\u5668\u7684\u76ee\u5f55\uff08\u65e0\u8bba\u662f\u865a\u62df\u73af\u5883\u8fd8\u662f\u7cfb\u7edf\u73af\u5883\uff09\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u4f60\u6709\u591a\u4e2a Python \u73af\u5883\u6216\u8005\u5e0c\u671b\u4e3a <code>uWSGI<\/code> \u6307\u5b9a\u7279\u5b9a\u7684 Python \u73af\u5883\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>home<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u603b\u7ed3<\/strong>:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <strong><code>virtualenv<\/code><\/strong> \u65f6\uff0c\u5b83\u4f1a\u8ba9 <code>uWSGI<\/code> \u4f7f\u7528\u6307\u5b9a\u8def\u5f84\u4e2d\u7684\u865a\u62df\u73af\u5883\uff0c\u81ea\u52a8\u4e3a\u865a\u62df\u73af\u5883\u914d\u7f6e Python \u89e3\u91ca\u5668\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 <strong><code>home<\/code><\/strong> \u65f6\uff0c\u5b83\u4f1a\u6307\u5b9a\u4e00\u4e2a Python \u73af\u5883\u8def\u5f84\uff0c\u901a\u5e38\u7528\u4e8e\u865a\u62df\u73af\u5883\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6307\u5411\u5176\u4ed6\u7684 Python \u73af\u5883\uff0c\u9002\u7528\u8303\u56f4\u66f4\u5e7f\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PYTHONPATH python \u603b\u7ed3 \u4e24\u8005\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\uff0cPYTHONPATH \u5f71\u54cd\u7684\u662f\u6a21\u5757\u67e5\u627e\u8def\u5f84\uff0c\u800c  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1033","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/comments?post=1033"}],"version-history":[{"count":1,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1033\/revisions"}],"predecessor-version":[{"id":1048,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1033\/revisions\/1048"}],"wp:attachment":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/media?parent=1033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/categories?post=1033"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/tags?post=1033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}