{"id":198984,"date":"2020-09-03T08:25:31","date_gmt":"2020-09-03T00:25:31","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=198984"},"modified":"2020-08-23T17:26:41","modified_gmt":"2020-08-23T09:26:41","slug":"ubuntu-16-04-python3-5-virtualenv","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ubuntu-16-04-python3-5-virtualenv.html","title":{"rendered":"ubuntu 16.04 \u865a\u62df\u73af\u5883 virtualenv \u5b89\u88c5\u6559\u7a0b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u6559\u4f60\u5982\u4f55\u5728 ubuntu 16.04 \u7cfb\u7edf\u91cc\u5b89\u88c5\u57fa\u4e8epython3.5\u7684\u865a\u62df\u73af\u5883virtualenv\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u73af\u5883\uff1aubuntu 16.04<\/p>\n

\u81ea\u5e26 python 2.7 \u548c python3.5<\/p>\n

\u5b89\u88c5\u6b65\u9aa4<\/strong><\/div>\n
1.\u5b89\u88c5virtualenv<\/strong><\/span><\/div>\n

\u6ce8\u610f\uff1a\u8fd9\u91cc\u4e0d\u8981\u7528sudo , \u7528\u8fc7sudo\u4f1a\u7528\u7cfb\u7edf\u81ea\u5e26\u7684\uff0c\u7136\u540e\u6ca1\u6709\u5b89\u88c5<\/p>\n

pip3 install virtualenv<\/pre>\n

pip3\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5<\/p>\n

sudo apt-get install python3-pip<\/pre>\n
#\u67e5\u770b\u662f\u5426\u5b89\u88c5\uff1a pip3 list\r\n\r\n#\u67e5\u770bpip3\u7248\u672c\u53f7: pip3 --version<\/pre>\n
2.\u5b89\u88c5virtualenvwrapper<\/strong><\/span><\/div>\n

\u8fd9\u91cc\u53ef\u4ee5\u7528sudo<\/p>\n

sudo pip3 install virtualenvwrapper<\/pre>\n
3.\u521b\u5efa\u865a\u62df\u73af\u5883\u7684\u76ee\u5f55<\/strong><\/span><\/div>\n

\u4ee5\u540e\u7684\u865a\u62df\u73af\u5883\u90fd\u653e\u7f6e\u5728\u8be5\u76ee\u5f55\u4e0b<\/p>\n

mkdir ~\/.virtualenvs<\/pre>\n
4.\u914d\u7f6evirtualenvwrapper<\/strong><\/span><\/div>\n
vim ~\/.bashrc<\/pre>\n
# \u6253\u5f00\u6587\u4ef6\u540e\u5728\u6587\u4ef6\u6700\u4e0b\u65b9\u589e\u52a0\u5982\u4e0b\u4ee3\u7801\r\n\r\nexport VIRTUALENVWRAPPER_PYTHON=\/usr\/bin\/python3\r\n\r\nexport WORKON_HOME=$HOME\/.virtualenvs\r\n\r\nsource \/usr\/local\/bin\/virtualenvwrapper.sh<\/pre>\n
5.\u4f7f\u5176\u751f\u6548<\/strong><\/span><\/div>\n
source ~\/.bashrc<\/pre>\n
6.\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/span><\/div>\n
mkvirtualenv \u865a\u62df\u73af\u5883\u540d\u79f0<\/pre>\n
#\u521b\u5efa\uff1amkvirtualenv [\u865a\u62df\u73af\u5883\u540d\u79f0]\r\n\r\n#\u5220\u9664\uff1armvirtualenv [\u865a\u62df\u73af\u5883\u540d\u79f0]\r\n\r\n#\u8fdb\u5165\uff1aworkon [\u865a\u62df\u73af\u5883\u540d\u79f0]\r\n\r\n#\u9000\u51fa\uff1adeactivate<\/pre>\n
\u671f\u95f4\u9047\u5230\u7684\u95ee\u9898\uff1a<\/strong><\/div>\n

\u5148\u76f4\u63a5\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u865a\u62df\u73af\u5883\uff0c\u5bfc\u81f4\u865a\u62df\u73af\u5883\u662f\u57fa\u4e8epython2.7\u7684.<\/p>\n

sudo apt-get install virtualenv\r\n\r\nsudo apt-get install virtualenvwrapper<\/pre>\n

\u8bf4\u660e\uff1avirtualenvwrapper.sh \u662f\u5b89\u88c5\u5728 \/usr\/share\/virtualenvwrapper\/virtualenvwrapper.sh<\/p>\n

\u914d\u7f6e\u597d~\/.bashrc\u4e4b\u540e\uff0c\u80fd\u8fd0\u884cvirtualenv \u547d\u4ee4\uff0c<\/p>\n

\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u865a\u62df\u73af\u5883\uff0c<\/p>\n

sudo apt-get remove virtualenv\r\n\r\nsudo apt-get remove virtualenvwrapper<\/pre>\n

\u540e\u6765\u518d\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u865a\u62df\u73af\u5883\uff0c\u57fa\u4e8epython3.5,<\/p>\n

sudo pip3 install virtualenv<\/pre>\n

\u63d0\u793a\u7cfb\u7edf\u5df2\u6709\u6ee1\u8db3\u7684virtualenv\uff0c\u5b9e\u9645\u4e0a\u8fd9\u4e2a\u547d\u4ee4\u6ca1\u6709\u5b89\u88c5virtualenv<\/p>\n

sudo pip3 install virtualenvwrapper<\/pre>\n

\u62a5\u4ee5\u4e0b\u9519\u8bef<\/p>\n

bash: \/usr\/share\/virtualenvwrapper\/virtualenvwrapper_lazy.sh: No such file or directory<\/pre>\n

\u5305\u62ec\u76f4\u63a5\u6253\u5f00\u7ec8\u7aef\u4e5f\u4f1a\u62a5\u4ee5\u4e0a\u9519\u8bef<\/p>\n

\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n

\u5220\u9664\/etc\/bash_completion.d\/virtualenvwrapper<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u73af\u5883\uff1aubuntu 16.04 \u81ea\u5e26 python 2.7 \u548c python3.5 \u6ce8\u610f\uff1a\u8fd9\u91cc\u4e0d\u8981\u7528sudo […]<\/p>\n","protected":false},"author":63,"featured_media":198990,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-198984","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\/198984","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=198984"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/198984\/revisions"}],"predecessor-version":[{"id":198986,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/198984\/revisions\/198986"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/198990"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=198984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=198984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=198984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}