{"id":554,"date":"2024-11-11T19:12:41","date_gmt":"2024-11-11T11:12:41","guid":{"rendered":"http:\/\/www.chan.ink\/?p=554"},"modified":"2024-11-11T19:13:06","modified_gmt":"2024-11-11T11:13:06","slug":"python%e8%99%9a%e6%8b%9f%e7%8e%af%e5%a2%83%e4%b8%8d%e5%8f%af%e7%a7%bb%e6%a4%8d","status":"publish","type":"post","link":"http:\/\/www.chan.ink\/index.php\/2024\/11\/11\/python%e8%99%9a%e6%8b%9f%e7%8e%af%e5%a2%83%e4%b8%8d%e5%8f%af%e7%a7%bb%e6%a4%8d\/","title":{"rendered":"Python\u865a\u62df\u73af\u5883\u4e0d\u53ef\u79fb\u690d"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2023\" height=\"582\" src=\"http:\/\/www.chan.ink\/wp-content\/uploads\/2024\/11\/7058ab37e4ab422b376d830d96e87d1.png\" alt=\"\" class=\"wp-image-556\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4e0d\u540c\u7535\u8111\u4e0a\u8fd0\u884c\u538b\u7f29\u540e\u7684\u9879\u76ee\u6587\u4ef6\u65f6\uff0c\u5373\u4f7f\u865a\u62df\u73af\u5883\u6587\u4ef6\u5939\u5b58\u5728\uff0c\u4e5f\u53ef\u80fd\u9047\u5230\u6a21\u5757\u4e22\u5931\u6216\u65e0\u6cd5\u8bc6\u522b\u7684\u95ee\u9898\u3002\u5e38\u89c1\u539f\u56e0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u865a\u62df\u73af\u5883\u8def\u5f84\u4e0d\u540c\uff1a\u865a\u62df\u73af\u5883\u901a\u5e38\u7ed1\u5b9a\u4e86\u521b\u5efa\u5b83\u7684\u7edd\u5bf9\u8def\u5f84\u3002\u5982\u679c\u4f60\u5728\u539f\u7535\u8111\u4e0a\u521b\u5efa\u4e86\u865a\u62df\u73af\u5883\uff0c\u5b83\u53ef\u80fd\u7ed1\u5b9a\u4e86\u5f53\u65f6\u7684\u8def\u5f84\uff08\u4f8b\u5982 C:\/Users\/OldUser\/myproject\/venv\uff09\u3002\u5728\u65b0\u7535\u8111\u4e0a\u89e3\u538b\u540e\u8def\u5f84\u53d8\u4e86\uff0c\u56e0\u6b64\u865a\u62df\u73af\u5883\u4e2d\u7684\u5305\u65e0\u6cd5\u88ab\u8bc6\u522b\u5230\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u64cd\u4f5c\u7cfb\u7edf\u6216 Python \u7248\u672c\u4e0d\u540c\uff1a\u5982\u679c\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u95f4\u8f6c\u79fb\uff08\u4f8b\u5982\u4ece Windows \u5230 Linux\uff09\uff0c\u6216\u8005 Python \u7248\u672c\u4e0d\u540c\uff08\u4f8b\u5982\u4ece Python 3.7 \u5230 Python 3.9\uff09\uff0c\u8fd9\u4e5f\u53ef\u80fd\u5bfc\u81f4\u865a\u62df\u73af\u5883\u4e2d\u7684\u5305\u4e0d\u53ef\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u73af\u5883\u672a\u6fc0\u6d3b\uff1a\u5728\u65b0\u7535\u8111\u4e0a\u8fd0\u884c\u65f6\u53ef\u80fd\u6ca1\u6709\u6b63\u786e\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u786e\u4fdd\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff08\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff09\u6765\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Windows: .\\venv\\Scripts\\activate<br>Linux\/Mac: source venv\/bin\/activate<br>\u4f7f\u7528 requirements.txt \u91cd\u5efa\u865a\u62df\u73af\u5883\uff1a \u4e00\u79cd\u66f4\u597d\u7684\u8fc1\u79fb\u65b9\u5f0f\u662f\u53ea\u5c06\u9879\u76ee\u7684\u6e90\u4ee3\u7801\u548c\u4f9d\u8d56\u6587\u4ef6\uff08\u4f8b\u5982 requirements.txt\uff09\u538b\u7f29\u6253\u5305\uff0c\u800c\u4e0d\u662f\u5305\u542b\u6574\u4e2a\u865a\u62df\u73af\u5883\u3002\u5728\u65b0\u7535\u8111\u4e0a\uff0c\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\u6765\u91cd\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>python -m venv venv # \u521b\u5efa\u65b0\u7684\u865a\u62df\u73af\u5883<br>source venv\/bin\/activate # \u6fc0\u6d3b\u865a\u62df\u73af\u5883<br>pip install -r requirements.txt # \u5b89\u88c5\u4f9d\u8d56<br>\u603b\u7ed3<br>\u901a\u5e38\uff0c\u628a\u865a\u62df\u73af\u5883\u6574\u4e2a\u590d\u5236\u5230\u5176\u4ed6\u7535\u8111\u4e0a\u8fd0\u884c\u4e0d\u4e00\u5b9a\u6709\u6548\u3002\u5efa\u8bae\u5728\u9879\u76ee\u4e2d\u6dfb\u52a0 requirements.txt \u6587\u4ef6\uff0c\u6309\u9700\u91cd\u5efa\u865a\u62df\u73af\u5883\uff0c\u4ee5\u786e\u4fdd\u73af\u5883\u7684\u517c\u5bb9\u6027\u548c\u4f9d\u8d56\u5b8c\u6574\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4e0d\u540c\u7535\u8111\u4e0a\u8fd0\u884c\u538b\u7f29\u540e\u7684\u9879\u76ee\u6587\u4ef6\u65f6\uff0c\u5373\u4f7f\u865a\u62df\u73af\u5883\u6587\u4ef6\u5939\u5b58\u5728\uff0c\u4e5f\u53ef\u80fd\u9047\u5230\u6a21\u5757\u4e22\u5931\u6216\u65e0\u6cd5\u8bc6\u522b\u7684\u95ee\u9898\u3002\u5e38\u89c1\u539f\u56e0\u5982\u4e0b\uff1a [&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-554","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/554","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=554"}],"version-history":[{"count":2,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/554\/revisions"}],"predecessor-version":[{"id":557,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/554\/revisions\/557"}],"wp:attachment":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/media?parent=554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/categories?post=554"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/tags?post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}