\r\nsudo pip3 install virtualenv\r\nsudo pip3 install virtualenvwrapper\r\n<\/pre>\n\u9700\u4fdd\u8bc1 Linux\u4e0a\u6709 Python3\u7684\u73af\u5883\u3002<\/p>\n
\u5b89\u88c5\u5b8c\u865a\u62df\u73af\u5883\u540e\u8f93\u5165\u5982\u4e0b\u6307\u4ee4\u6d4b\u8bd5<\/p>\n
\r\nmkvirtualenv test\r\n<\/pre>\n\u5982\u679c\u63d0\u793a\u627e\u4e0d\u5230mkvirtualenv\u547d\u4ee4\uff0c\u987b\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n
\r\n# 1\u3001\u521b\u5efa\u76ee\u5f55\u7528\u6765\u5b58\u653e\u865a\u62df\u73af\u5883\r\nmkdir $HOME\/.virtualenvs\r\n \r\n# 2\u3001\u6253\u5f00~\/.bashrc\u6587\u4ef6\r\nvim ~\/.bashrc\r\n \r\n# 2.1 \u6dfb\u52a0\u5982\u4e0b\u4e24\u884c\r\nexport WORKON_HOME=$HOME\/.virtualenvs\r\nsource \/usr\/local\/bin\/virtualenvwrapper.sh\r\n \r\n# 3\u3001\u8fd0\u884c\r\nsource ~\/.bashrc\r\n<\/pre>\nWORKON_HOME \u5b58\u653e\u865a\u62df\u73af\u5883\u76ee\u5f55\u4f4d\u7f6e\u53ef\u4ee5\u81ea\u5df1\u5355\u72ec\u8bbe\u7f6e\u3002<\/p>\n
\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/span><\/div>\n\r\nmkvirtualenv py_flask\r\n<\/pre>\n\u8fdb\u5165\u865a\u62df\u73af\u5883<\/strong><\/span><\/div>\n\r\nworkon py_flask\r\n<\/pre>\n\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong><\/span><\/div>\n\u5982\u679c\u6240\u5728\u73af\u5883\u4e3a\u771f\u5b9e\u73af\u5883\uff0c\u4f1a\u63d0\u793adeactivate\uff1a\u672a\u627e\u5230\u547d\u4ee4<\/p>\n
\r\ndeactivate py_flask\r\n<\/pre>\n\u865a\u62df\u73af\u5883\u6307\u4ee4<\/strong><\/div>\nWindows \u548c Linux \u5e73\u53f0\u4e0a\u7684\u6307\u4ee4\u90fd\u4e00\u81f4\u3002<\/p>\n
<\/p>\n
\u6ce8\u610f\uff1a<\/p>\n
\r\n\u5148\u9000\u51fa\uff1adeactivate\r\n\u518d\u5220\u9664\uff1armvirtualenv \u865a\u62df\u73af\u5883\u540d\u79f0\r\n<\/pre>\n\u865a\u62df\u73af\u5883\u603b\u7ed3<\/strong><\/div>\n\u4e00\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u4e0d\u4f1a\u8ba9\u4e3b\u89e3\u91ca\u5668\u597d\u591a\u5e93\u4e71<\/p>\n
\u4e8c\u3001\u4f8b\u5982\u5728\u5355\u72ec\u7684\u865a\u62df\u73af\u5883\u4e0b\u5b89\u88c5 Flask\uff0c\u5c31\u77e5\u9053\u5728\u540e\u7eed\u5f00\u53d1\u4e2d\u6240\u4f7f\u7528\u7684\u6240\u6709\u5e93\uff0c\u7528pip freeze\u547d\u4ee4\u5c31\u77e5\u9053\u4f60\u7684\u9879\u76ee\u9700\u8981\u4ec0\u4e48\u73af\u5883\uff0c\u800c\u5728\u4e3b\u89e3\u91ca\u5668\u6709\u597d\u591a\u9879\u76ee\u6ca1\u7528\u5230\u7684\u5e93\u3002\u4f7f\u7528\u865a\u62df\u73af\u5883\u5230\u90e8\u7f72\u5230\u670d\u52a1\u5668\u4e0a\u5219\u65b9\u4fbf\u73af\u5883\u914d\u7f6e\uff0c\u4e0d\u9700\u8981\u4e00\u4e2a\u4e00\u4e2a\u7b5b\u9009\u6240\u9700\u5e93\u3002<\/p>\n
\u5728\u865a\u62df\u73af\u5883\u4e2d\u5229\u7528<\/strong><\/span><\/div>\npip freeze \u67e5\u770b\u9879\u76ee\u6240\u9700\u5e93\u73af\u5883\u3002<\/p>\n
pip freeze > requirements.txt\u5bfc\u51fa\u9879\u76ee\u6240\u9700\u5e93\u4fe1\u606f\u3002<\/p>\n
pip install -r requirements.tx\u6279\u91cf\u5b89\u88c5\u9879\u76ee\u6240\u9700\u5e93\u3002<\/p>\n
\u4e09\u3001\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u5f00\u53d1\u591a\u4e2a\u9879\u76ee\uff0c\u800c\u9047\u5230\u9879\u76ee\u6240\u9700\u540c\u4e00\u5e93\u7684\u7248\u672c\u4e0d\u4e00\u81f4\u3002\u56e0\u6b64\u4f7f\u7528\u865a\u62df\u73af\u5883\u8ba9\u6bcf\u4e2a\u9879\u76ee\u72ec\u7acb\u9694\u79bb\u51fa\u6765\uff0c\u53ef\u4ee5\u5355\u72ec\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u5e93\u3002<\/p>\n
\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8ePython\u865a\u62df\u73af\u5883virtualenv\u662f\u5982\u4f55\u4f7f\u7528\u7684\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5982\u679c\u5728\u4e00\u53f0\u673a\u5668\u4e0a\uff0c\u60f3\u5f00\u53d1\u591a\u4e2a\u4e0d\u540c\u7684\u9879\u76ee\uff0c\u9700\u8981\u7528\u5230\u540c\u4e00\u4e2a\u5305\u7684\u4e0d\u540c\u7248\u672c\uff0c\u5982\u679c\u8fd8\u4f7f\u7528\u4e0a\u9762\u7684\u547d\u4ee4\uff0c\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u4e0b\u5b89\u88c5\u6216 […]<\/p>\n","protected":false},"author":668,"featured_media":100858,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-221461","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=221461"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221461\/revisions"}],"predecessor-version":[{"id":221467,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221461\/revisions\/221467"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/100858"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=221461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=221461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=221461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}