{"id":356,"date":"2024-12-03T11:06:34","date_gmt":"2024-12-03T03:06:34","guid":{"rendered":"https:\/\/znl.pub\/?p=356"},"modified":"2024-12-03T11:06:34","modified_gmt":"2024-12-03T03:06:34","slug":"python%e4%b9%8b%e8%99%9a%e6%8b%9f%e7%9b%ae%e5%bd%95%ef%bc%88%e6%88%96%e7%a7%b0%e8%99%9a%e6%8b%9f%e7%8e%af%e5%a2%83%e3%80%81%e8%99%9a%e6%8b%9f%e7%a9%ba%e9%97%b4%ef%bc%89","status":"publish","type":"post","link":"https:\/\/znl.pub\/?p=356","title":{"rendered":"python\u4e4b\u865a\u62df\u76ee\u5f55\uff08\u6216\u79f0\u865a\u62df\u73af\u5883\u3001\u865a\u62df\u7a7a\u95f4\uff09"},"content":{"rendered":"\n<p>\u6709\u65f6\u5019\u6211\u4eec\u4e0d\u5e0c\u671bpython\u5404\u79cd\u4f9d\u8d56\u4e4b\u95f4\u53d1\u751f\u51b2\u7a81\uff0c\u6216\u8005\u6211\u4eec\u5e0c\u671b\u80fd\u5c06\u81ea\u5df1\u5199\u7684\u7a0b\u5e8f\u9700\u8981\u7528\u5230\u7684\u4f9d\u8d56\u90fd\u653e\u5728\u4e00\u4e2a\u76ee\u5f55\u91cc\u9762\uff0c\u5c31\u597d\u6bd4nodejs\u7684\u9879\u76ee\u6216\u8005php\u7684\u9879\u76ee\uff0c\u6211\u4eec\u6267\u884cpip\u5b89\u88c5\u7684\u5305\u4e5f\u5168\u90fd\u5230\u5f53\u524d\u76ee\u5f55\u624d\u597d\u3002\u5b9e\u9645\u4e0apython\u4e3a\u6211\u4eec\u51c6\u5907\u4e86\u8fd9\u6837\u7684\u6a21\u5757\u6765\u5b9e\u73b0\u201c\u865a\u62df\u73af\u5883\u201d\uff0c\u5b9e\u73b0\u76ee\u5f55\u7a7a\u95f4\u9650\u5b9a\uff0c\u8fd9\u4e2a\u6a21\u5757\u5c31\u53eb &#8216;venv&#8217; (pip\u5b89\u88c5virtualenv \u540e\u53ef\u5f97\u6b64\u6a21\u5757\uff09\u3002<\/p>\n\n\n\n<p>\u672c\u6587\u4e3b\u8981\u76ee\u7684\u662f\u4e3a\u8bb0\u5f55\u81ea\u5df1\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u7684\u5173\u952e\u4fe1\u606f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1. \u9996\u5148\uff0c\u770b\u4e00\u4e0b\u5f53\u524d\u7684\u73af\u5883\u91cc\u662f\u5426\u5df2\u7ecf\u6709\u4e86\u8fd9\u4e2a\u6a21\u5757<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 list --format=columns | grep virtualenv\n#--format=columns\u52a0\u4e0d\u52a0\u90fd\u884c\uff0c\u4e5f\u5c31\u662f\u8fd8\u53ef\u4ee5\u8fd9\u4e48\u7528:\npip3 list | grep virtu<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>2. \u5982\u679c\u4e0d\u5b58\u5728\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5\u6b64\u6a21\u5757\uff0c\u5982\u679c\u5b58\u5728\uff0c\u8bf7\u8df3\u8fc7\u672c\u6bb5\u843d<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@znl.pub ~]# pip3 install virtualenv\n&#91;root@znl.pub ~]# pip3 list --format=columns | grep virtu\nvirtualenv          20.17.1<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>3. \u6211\u8ba1\u5212\u521b\u5efa\u76ee\u5f55 \/home\/znl\/py3.6-jupyter.ve \uff0c\u4f7f\u7528venv\u8fd9\u4e2a\u6a21\u5757<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@znl.pub \/]# mkdir \/home\/znl\n&#91;root@znl.pub \/]# cd \/home\/znl\n&#91;root@znl.pub znl]# python3.6 -m venv py3.6-jupyter.ve\n&#91;root@znl.pub znl]# cd py3.6-jupyter.ve\/\n&#91;root@znl.pub py3.6-jupyter.ve]# ls -la \ntotal 24\ndrwxr-xr-x 5 root root 4096 Nov 20 09:59 .\ndrwxr-xr-x 3 root root 4096 Nov 20 09:59 ..\ndrwxr-xr-x 2 root root 4096 Nov 20 09:59 bin\ndrwxr-xr-x 2 root root 4096 Nov 20 09:59 include\ndrwxr-xr-x 3 root root 4096 Nov 20 09:59 lib\nlrwxrwxrwx 1 root root    3 Nov 20 09:59 lib64 -> lib\n-rw-r--r-- 1 root root   69 Nov 20 09:59 pyvenv.cfg<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>4. \u6fc0\u6d3b\u865a\u62df\u7a7a\u95f4\uff0c\u7b2c3\u6b65\u4f1a\u5728py3.6-jupyter.ve \u4e2d\u521b\u5efa\u4e00\u4e9b\u5fc5\u8981\u6587\u4ef6\uff0c\u5b9e\u9645\u4e0a\u5230\u7b2c\u4e09\u6b65\u865a\u62df\u76ee\u5f55\u5c31\u521b\u5efa\u597d\u4e86<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@znl.pub py3.6-jupyter.ve]# source bin\/activate\n(py3.6-jupyter.ve) &#91;root@znl.pub ~]# <\/code><\/pre>\n\n\n\n<p>\u6216\u52a0\u8f7d\u5168\u8def\u5f84\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@znl.pub py3.6-jupyter.ve]# source \/home\/znl\/py3.6-jupyter.ve\/bin\/activate\n(py3.6-jupyter.ve) &#91;root@znl.pub ~]# <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>5. \u9000\u51fa\u5f53\u524d\u73af\u5883\uff0c\u5f53\u91c7\u7528source bin\/activate\u6fc0\u6d3b\u73af\u5883\u7684\u65f6\u5019\uff0c\u5b9e\u9645\u4e0a\u4f1a\u521b\u5efa\u4e00\u4e2a\u53ebdeactivate\u7684\u51fd\u6570<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>(py3.6-jupyter.ve) &#91;root@znl.pub ~]# disactive<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u65f6\u5019\u6211\u4eec\u4e0d\u5e0c\u671bpython\u5404\u79cd\u4f9d\u8d56\u4e4b\u95f4\u53d1\u751f\u51b2\u7a81\uff0c\u6216\u8005\u6211\u4eec\u5e0c\u671b\u80fd\u5c06\u81ea\u5df1\u5199\u7684\u7a0b\u5e8f\u9700\u8981\u7528\u5230\u7684\u4f9d\u8d56\u90fd\u653e\u5728\u4e00\u4e2a\u76ee\u5f55\u91cc\u9762&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-356","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts\/356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=356"}],"version-history":[{"count":1,"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":357,"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions\/357"}],"wp:attachment":[{"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}