﻿{"id":609,"date":"2020-11-23T07:30:50","date_gmt":"2020-11-22T23:30:50","guid":{"rendered":"https:\/\/byy3.com\/?p=609"},"modified":"2021-01-09T10:14:00","modified_gmt":"2021-01-09T02:14:00","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae%e5%9c%a8%e7%ba%bfpython%e7%bc%96%e7%a8%8bjupyter-notebook%ef%bc%9a%e5%bf%ab%e9%80%9f%e5%bc%80%e5%a7%8b%e6%95%b0%e6%8d%ae%e7%a7%91%e5%ad%a6","status":"publish","type":"post","link":"https:\/\/byy3.com\/?p=609","title":{"rendered":"\u670d\u52a1\u5668\u914d\u7f6e\u5728\u7ebfpython\u7f16\u7a0bjupyter notebook\uff1a\u5feb\u901f\u5f00\u59cb\u6570\u636e\u79d1\u5b66"},"content":{"rendered":"<p>\u672c\u6587\u8bb0\u5f55\u4e00\u4e0b\uff0c\u65b0\u670d\u52a1\u5668\u7684\u914d\u7f6e\u8fc7\u7a0b\uff0c\u5feb\u901f\u5f00\u59cb\u6570\u636e\u79d1\u5b66\u51b2\u6d6a\u3002<\/p>\n<p>\u4ee5\u963f\u91cc\u4e91\u670d\u52a1\u5668\u4e3a\u4f8b\uff0c\u8bb0\u5f97\u521b\u5efa\u5b8c\u5b9e\u4f8b\u540e\uff0c\u6709\u65f6\u5019\u9700\u8981\u91cd\u542f\u4e00\u4e0b\u670d\u52a1\u5668\uff0c\u624d\u80fd\u8fdc\u7a0bssh\uff01\u5207\u8bb0\uff01<\/p>\n<h2 id=\"1-\u670d\u52a1\u5668\u57fa\u672c\u914d\u7f6e\">1. \u670d\u52a1\u5668\u57fa\u672c\u914d\u7f6e<\/h2>\n<p>\u7528root\u7528\u6237\uff0cssh\u4e0a\u53bb\u4e4b\u540e\uff0c\u53ef\u4ee5\u65b0\u5efa\u4e00\u4e2a\u7528\u6237\u7528\u4e8e\u65e5\u5e38\u4f7f\u7528\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u65b0\u521b\u5efa\u7684\u7528\u6237\u662f\u4e0d\u5177\u6709 root \u6743\u9650\u7684\uff0c\u4e5f\u4e0d\u5728 sudo \u7528\u6237\u7ec4\uff0c\u53ef\u4ee5\u8ba9\u5176\u52a0\u5165 sudo \u7528\u6237\u7ec4\u4ece\u800c\u83b7\u53d6 root \u6743\u9650\u3002<\/p>\n<p>\u5728 Linux \u7cfb\u7edf\u91cc\uff0c\u00a0<code>root<\/code>\u8d26\u6237\u62e5\u6709\u6574\u4e2a\u7cfb\u7edf\u81f3\u9ad8\u65e0\u4e0a\u7684\u6743\u5229\uff0c\u6bd4\u5982\u00a0<strong>\u65b0\u5efa\/\u6dfb\u52a0<\/strong>\u00a0\u7528\u6237\u3002<\/p>\n<blockquote><p>root \u6743\u9650\uff0c\u7cfb\u7edf\u6743\u9650\u7684\u4e00\u79cd\uff0c\u4e0e SYSTEM \u6743\u9650\u53ef\u4ee5\u7406\u89e3\u6210\u4e00\u4e2a\u6982\u5ff5\uff0c\u4f46\u9ad8\u4e8e Administrator \u6743\u9650\uff0croot \u662f Linux \u548c UNIX \u7cfb\u7edf\u4e2d\u7684\u8d85\u7ea7\u7ba1\u7406\u5458\u7528\u6237\u5e10\u6237\uff0c\u8be5\u5e10\u6237\u62e5\u6709\u6574\u4e2a\u7cfb\u7edf\u81f3\u9ad8\u65e0\u4e0a\u7684\u6743\u529b\uff0c\u6240\u6709\u5bf9\u8c61\u4ed6\u90fd\u53ef\u4ee5\u64cd\u4f5c\uff0c\u6240\u4ee5\u5f88\u591a\u9ed1\u5ba2\u5728\u5165\u4fb5\u7cfb\u7edf\u7684\u65f6\u5019\uff0c\u90fd\u8981\u628a\u6743\u9650\u63d0\u5347\u5230 root \u6743\u9650\uff0c\u7528 Windows \u7684\u65b9\u6cd5\u7406\u89e3\u4e5f\u5c31\u662f\u5c06\u81ea\u5df1\u7684\u975e\u6cd5\u5e10\u6237\u6dfb\u52a0\u5230 Administrators \u7528\u6237\u7ec4\u3002\u66f4\u6bd4\u5982\u5b89\u5353\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff08\u57fa\u4e8e Linux \u5185\u6838\uff09\u83b7\u5f97 root \u6743\u9650\u4e4b\u540e\u5c31\u610f\u5473\u7740\u5df2\u7ecf\u83b7\u5f97\u4e86\u624b\u673a\u7684\u6700\u9ad8\u6743\u9650\uff0c\u8fd9\u65f6\u5019\u4f60\u53ef\u4ee5\u5bf9\u624b\u673a\u4e2d\u7684\u4efb\u4f55\u6587\u4ef6\uff08\u5305\u62ec\u7cfb\u7edf\u6587\u4ef6\uff09\u6267\u884c\u6240\u6709\u589e\u3001\u5220\u3001\u6539\u3001\u67e5\u7684\u64cd\u4f5c\u3002<\/p><\/blockquote>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\">sudo adduser NEWUSER # \u521b\u5efa\u7528\u6237\r\nsudo usermod -G sudo NEWUSER # \u52a0\u5165sudo\u7ec4\r\ngroups NEWUSER # \u67e5\u770b\u5206\u7ec4\r\nsu NEWUSER # \u5207\u6362\u7528\u6237<\/code><\/pre>\n<\/div>\n<p>\u66f4\u591a\uff1a<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\"># \u5982\u679c\u8981\u5220\u9664\u7528\u6237\r\nsudo deluser NEWUSER --remove-home\r\n# \u4fee\u6539\u5bc6\u7801\r\npasswd<\/code><\/pre>\n<\/div>\n<h2 id=\"2-\u5b89\u88c5miniconda\">2. \u5b89\u88c5miniconda<\/h2>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\"># linux:\r\nwget <a class=\"vglnk\" href=\"https:\/\/byy3.com\/go\/?url=https:\/\/repo.continuum.io\/miniconda\/Miniconda3-latest-Linux-x86_64.sh\" rel=\"nofollow\">https:\/\/repo.continuum.io\/miniconda\/Miniconda3-latest-Linux-x86_64.sh<\/a> &amp;&amp; bash Miniconda3-latest-Linux-x86_64.sh\r\n \r\n# \u5982\u679c\u662fmac:\r\nwget <a class=\"vglnk\" href=\"https:\/\/byy3.com\/go\/?url=https:\/\/repo.continuum.io\/miniconda\/Miniconda3-latest-MacOSX-x86_64.sh\" rel=\"nofollow\">https:\/\/repo.continuum.io\/miniconda\/Miniconda3-latest-MacOSX-x86_64.sh<\/a> &amp;&amp; bash Miniconda3-latest-Linux-x86_64.sh<\/code><\/pre>\n<\/div>\n<h2 id=\"3-\u5f00jupyter\u65b9\u4fbf\u8fdc\u7a0b\u8fde\u63a5\">3. \u5f00jupyter\u65b9\u4fbf\u8fdc\u7a0b\u8fde\u63a5<\/h2>\n<p>\u5b89\u88c5jupyter\uff1a<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\">conda install -y -c anaconda jupyter<\/code><\/pre>\n<\/div>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p>\uff081\uff09\u5728\u963f\u91cc\u4e91\u540e\u53f0\uff0c\u6253\u5f00\u76f8\u5e94\u7684\u7aef\u53e3\uff0c\u6bd4\u5982\u6211\u4eec\u8fd9\u91cc\u6253\u5f008055\u7aef\u53e3<\/p>\n<p><img decoding=\"async\" data-original=\"https:\/\/www.zhangqibot.com\/post\/pics\/image-20190820144107773.png\" src=\"https:\/\/byy3.com\/wp-content\/themes\/MNews%20V2.4\/images\/post-loading.gif\" title=\"\u670d\u52a1\u5668\u914d\u7f6e\u5728\u7ebfpython\u7f16\u7a0bjupyter notebook\uff1a\u5feb\u901f\u5f00\u59cb\u6570\u636e\u79d1\u5b66\u63d2\u56fe\" alt=\"\u670d\u52a1\u5668\u914d\u7f6e\u5728\u7ebfpython\u7f16\u7a0bjupyter notebook\uff1a\u5feb\u901f\u5f00\u59cb\u6570\u636e\u79d1\u5b66\u63d2\u56fe\" \/><\/p>\n<p>\uff082\uff09\u5b89\u88c5\u5b8cjupyter\u540e\uff0c\u8f93\u5165<code>$ jupyter notebook --generate-config<\/code>\u4ea7\u751f\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>\uff083\uff09\u8fdb\u5165ipython\uff0c\u914d\u7f6e\u5bc6\u7801\uff0c\u8bb0\u4e0b\u5bc6\u7801\uff08\u7528\u4e8e\u767b\u5f55\uff09\uff0c\u5e76\u590d\u5236hash\u7801<code>sha1:...<\/code>\uff08\u7528\u4e8e\u914d\u7f6e\uff09\uff1a<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">In [1]: from notebook.auth import passwd\r\nIn [2]: passwd()\r\nEnter password:\r\nVerify password:\r\nOut[2]: 'sha1:67c9e60bb8b6:9f*****4254b2e042ea597d771089e11aed'<\/code><\/pre>\n<\/div>\n<p>\uff084\uff09\u7f16\u8f91jupyter\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\">$ vi .jupyter\/jupyter_notebook_config.py<\/code><\/pre>\n<\/div>\n<p>\u6dfb\u52a0\uff1a<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">c.NotebookApp.ip='*' # \u5982\u679c\u4e0d\u884c\uff0c\u4f7f\u7528 '0.0.0.0'\r\nc.NotebookApp.notebook_dir = u''\r\nc.NotebookApp.open_browser = False\r\nc.NotebookApp.password = 'sha1:67c9e60bb8b6:9f*****4254b2e042ea597d771089e11aed'\r\nc.NotebookApp.port =8055<\/code><\/pre>\n<\/div>\n<p>\u4fdd\u5b58\u9000\u51fa\u3002<\/p>\n<p>\uff085\uff09\u8fd0\u884cjupyter<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\">$ nohup jupyter notebook &gt;&gt; jupyter.out 2&gt;&amp;1 &amp;<\/code><\/pre>\n<\/div>\n<p>\u5373\u53ef\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u3002<\/p>\n<p><a href=\"https:\/\/byy3.com\/go\/?url=http:\/\/yourhost:8055%EF%BC%8C\/\" rel=\"nofollow\" >http:\/\/yourhost:8055\uff0c<\/a>\u00a0\u5bc6\u7801\u662f\u4f60\u5728ipython\u91cc\u8bbe\u7f6e\u7684\u5bc6\u7801\u3002<\/p>\n<hr \/>\n<p>\u53ef\u4ee5\u5199\u6210shell\uff0c<code>environment_initiate.sh<\/code>\uff1a<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\">mkdir download\r\ncd download &amp;&amp; wget <a class=\"vglnk\" href=\"https:\/\/byy3.com\/go\/?url=https:\/\/repo.continuum.io\/miniconda\/Miniconda3-latest-Linux-x86_64.sh\" rel=\"nofollow\">https:\/\/repo.continuum.io\/miniconda\/Miniconda3-latest-Linux-x86_64.sh<\/a> &amp;&amp; bash Miniconda3-latest-Linux-x86_64.sh \r\n#update anaconda path\r\nsource ~\/.bashrc\r\n# \u6dfb\u52a0\u56fd\u5185\u7684\u6e90\r\nconda config --add channels <a class=\"vglnk\" href=\"https:\/\/byy3.com\/go\/?url=https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/pkgs\/free\/\" rel=\"nofollow\">https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/pkgs\/free\/<\/a>\r\nconda config --add channels <a class=\"vglnk\" href=\"https:\/\/byy3.com\/go\/?url=https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/pkgs\/main\/\" rel=\"nofollow\">https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/pkgs\/main\/<\/a>\r\nconda config --add channels <a class=\"vglnk\" href=\"https:\/\/byy3.com\/go\/?url=https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/cloud\/conda-forge\/\" rel=\"nofollow\">https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/cloud\/conda-forge\/<\/a>\r\nconda config --set show_channel_urls yes\r\nconda install -y -c anaconda jupyter\r\njupyter notebook --generate-config<\/code><\/pre>\n<\/div>\n<h2 id=\"4-\u5b89\u88c5\u9700\u8981\u7684\u5e93-\u5f00\u6574\">4. \u5b89\u88c5\u9700\u8981\u7684\u5e93\uff0c\u5f00\u6574<\/h2>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\">conda install -y tqdm numpy pandas scipy matplotlib seaborn scikit-learn lightgbm xgboost catboost<\/code><\/pre>\n<\/div>\n<p>\u6216\u8005\u901a\u8fc7requirements.txt<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-bash\" data-lang=\"bash\"># conda\u6279\u91cf\u5bfc\u51fa\u5305\u542b\u73af\u5883\u4e2d\u6240\u6709\u7ec4\u4ef6\u7684requirements.txt\u6587\u4ef6\r\nconda list -e &gt; requirements.txt\r\n# pip\u6279\u91cf\u5b89\u88c5requirements.txt\u6587\u4ef6\u4e2d\u5305\u542b\u7684\u7ec4\u4ef6\u4f9d\u8d56\r\nconda install --yes --file requirements.txt<\/code><\/pre>\n<\/div>\n<p>\u6216\u8005\u901a\u8fc7dockerfile?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u8bb0\u5f55\u4e00\u4e0b\uff0c\u65b0\u670d\u52a1\u5668\u7684\u914d\u7f6e\u8fc7\u7a0b\uff0c\u5feb\u901f\u5f00\u59cb\u6570\u636e\u79d1\u5b66\u51b2\u6d6a\u3002 \u4ee5\u963f\u91cc\u4e91\u670d\u52a1\u5668\u4e3a\u4f8b\uff0c\u8bb0\u5f97\u521b\u5efa\u5b8c\u5b9e\u4f8b\u540e\uff0c\u6709\u65f6\u5019\u9700\u8981\u91cd\u542f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,20],"tags":[110,353,33,352,114,112,113,111],"class_list":["post-609","post","type-post","status-publish","format-standard","hentry","category-linux","category-python","tag-jupyter-notebook","tag-linux","tag-python"],"_links":{"self":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=609"}],"version-history":[{"count":0,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/609\/revisions"}],"wp:attachment":[{"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}