{"id":10007039,"date":"2023-01-04T12:16:14","date_gmt":"2023-01-04T04:16:14","guid":{"rendered":"https:\/\/ityet.com\/?p=10007039"},"modified":"2023-01-04T12:16:14","modified_gmt":"2023-01-04T04:16:14","slug":"jupyter-notebook%e5%85%a5%e9%97%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10007039","title":{"rendered":"Jupyter Notebook\u5165\u95e8\u6307\u5357"},"content":{"rendered":"<h6>\u4f5c\u8005\uff1a\u4eac\u4e1c\u79d1\u6280\u9690\u79c1\u8ba1\u7b97\u4ea7\u54c1\u90e8 \u5b59\u6653\u519b<\/h6>\n<h2><strong>1. Jupyter Notebook\u4ecb\u7ecd<\/strong><\/h2>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228516\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe1 Jupter\u9879\u76ee\u6574\u4f53\u67b6\u6784<\/p>\n<p>[<a href=\"https:\/\/link.segmentfault.com\/?enc=SX%2B7CSPn5N34r7wj%2FiU%2Bvw%3D%3D.FIkMD%2B34TOY3u1kYjz7vJzzOjcf7av2ODUlhgZcjFAWwrdD5zSOCaBzYYL%2FMdKii6uyBxtdr2rMJQgpJvlH4UEbvbc%2FZwXUfKN6qPpRQGJIZj4NBC72RKBXHSffC3GA%2B\" rel=\"nofollow\">https:\/\/docs.jupyter.org\/en\/l&#8230;<\/a>]<\/p>\n<p>Jupyter Notebook\u662f\u4e00\u5957\u57fa\u4e8eweb\u7684\u4ea4\u4e92\u5f0f\u5f00\u53d1\u73af\u5883\u3002\u7528\u6237\u53ef\u4ee5\u5728\u7ebf\u5f00\u53d1\u548c\u5206\u4eab\u5305\u542b\u4ee3\u7801\u548c\u8f93\u51fa\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\uff0c\u652f\u6301\u5b9e\u65f6\u4ee3\u7801\uff0c\u6570\u5b66\u65b9\u7a0b\uff0c\u53ef\u89c6\u5316\u548c markdown\u7b49\u3002\u7528\u9014\u5305\u62ec\uff1a\u6570\u636e\u6e05\u7406\u548c\u8f6c\u6362\uff0c\u6570\u503c\u6a21\u62df\uff0c\u7edf\u8ba1\u5efa\u6a21\uff0c\u673a\u5668\u5b66\u4e60\u7b49\u7b49\u3002<\/p>\n<p>Jupyter Notebook\u5185\u90e8\u901a\u8fc7\u5185\u6838\u7ef4\u62a4\u72b6\u6001\u5e76\u8fd0\u884c\u4ee3\u7801\u7247\u6bb5\uff0c\u6d4f\u89c8\u5668\u663e\u793a\u4ee3\u7801\u7247\u6bb5\u548c\u5176\u6267\u884c\u7684\u7ed3\u679c\u3002Jupyter Notebook\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7528\u6237\u4ea4\u4e92\u5f0f\u7684\u5f00\u53d1\u73af\u5883\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u6267\u884c\u4e00\u90e8\u5206\u4ee3\u7801\u7247\u6bb5\uff0c\u5e76\u89c2\u5bdf\u6267\u884c\u7ed3\u679c\u3002\u8fd9\u79cd\u4ea4\u4e92\u5f0f\u8bbe\u8ba1\uff0c\u4f7f\u5f97Jupyter Notebook\u975e\u5e38\u9002\u5408\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u7684\u5f00\u53d1\u5de5\u4f5c\u3002<\/p>\n<p>\u6ce8\u610f\u672c\u6587\u7684\u4ee3\u7801\u548c\u811a\u672c\uff0c\u5747\u57fa\u4e8eJupyter Notebook v6.5.2\u7a33\u5b9a\u7248\u672c\u3002<\/p>\n<h2><strong>2. Jupyter\u7684\u5de5\u4f5c\u65b9\u5f0f<\/strong><\/h2>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228517\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe2 Jupter Notebook\u5de5\u4f5c\u65b9\u5f0f<\/p>\n<p>[<a href=\"https:\/\/link.segmentfault.com\/?enc=raINOfN5u4XE2Plm6QfHvQ%3D%3D.%2BSeOXp2QR6Vv0OJ5XlTYywUZMs6j%2FzZvaNcskh1Sqnfx3uZzqZJLJtoEqGq4aIchsnuZyFMZaM%2FGto60wuXo%2FJlTJl5sHcIhJA%2BSZSzcNwalvukqiHdyt8l6HnwOtt1r\" rel=\"nofollow\">https:\/\/docs.jupyter.org\/en\/l&#8230;<\/a>]<\/p>\n<p>Jupyter\u7684\u4e3b\u8981\u5de5\u4f5c\u5355\u5143\u662fJupyter Server\u548cKernel\u3002\u5176\u4e2dJupyter Server\u7528\u6765\u63d0\u4f9b\u57fa\u4e8eWeb\u7684\u754c\u9762\u548cAPI\u670d\u52a1\uff0cKernel\u7528\u6765\u6267\u884c\u4ee3\u7801\u7247\u6bb5\u3002\u6d4f\u89c8\u5668\u901a\u8fc7Http\u548cWebsockets\u7684\u65b9\u5f0f\u548cJupyter Server\u8fdb\u884c\u4ea4\u4e92\uff0cJupyter Server\u548ckernel\u4e4b\u95f4\uff0c\u901a\u8fc7ZeroMQ\u8fdb\u884c\u6570\u636e\u901a\u4fe1\u3002<\/p>\n<p>Jupyter Server\u91c7\u7528\u7ecf\u5178\u7684MVC\u6a21\u5f0f\uff0c\u4f7f\u7528\u4e86tornado\u4f5c\u4e3aweb\u670d\u52a1\u5668\uff0c\u7528\u6765\u63d0\u4f9b\u5730\u5740\u6620\u5c04\u548c\u63a7\u5236\u5668\u903b\u8f91\uff0c\u4f7f\u7528jinja2\u6765\u63d0\u4f9b\u6a21\u677f\u89c6\u56fe\u529f\u80fd\u3002<\/p>\n<p>Jupyter Notebook\uff08v6.5.2\uff09\u9879\u76ee\u7684\u4e3b\u8981\u6a21\u5757\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6a21\u5757<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>notebook<\/td>\n<td>Notebook\u529f\u80fd\u6a21\u5757\u3002<\/td>\n<\/tr>\n<tr>\n<td>terminal<\/td>\n<td>\u7ec8\u7aef\u6a21\u5757\u3002\u4e3aJupyter\u63d0\u4f9b\u63a7\u5236\u53f0\u4ea4\u4e92\u80fd\u529b\u3002<\/td>\n<\/tr>\n<tr>\n<td>view<\/td>\n<td>\u6587\u4ef6\u53ef\u89c6\u5316\u6a21\u5757\u3002\u6bd4\u5982pdf\u6587\u4ef6\u7684\u663e\u793a\u3002<\/td>\n<\/tr>\n<tr>\n<td>tree<\/td>\n<td>\u5de5\u4f5c\u533a\u76ee\u5f55\u6811<\/td>\n<\/tr>\n<tr>\n<td>nbconvert<\/td>\n<td>\u683c\u5f0f\u8f6c\u6362\u6a21\u5757\uff0c\u53ef\u4ee5\u628aJupyter Notebook\u8f6c\u6362\u6210html\uff0cpdf\u7b49\u683c\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>kernel<\/td>\n<td>Jupyter Notebook \u5185\u6838<\/td>\n<\/tr>\n<tr>\n<td>services<\/td>\n<td>Jupyter Notebook REST API\u6a21\u5757<\/td>\n<\/tr>\n<tr>\n<td>i18n<\/td>\n<td>Jupyter Notebook\u591a\u8bed\u8a00\u8d44\u6e90<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><strong>3. \u5b89\u88c5Jupyter Notebook<\/strong><\/h2>\n<p><strong>\u524d\u7f6e\u6761\u4ef6<\/strong><\/p>\n<p>Python\u548cpip<\/p>\n<p>\u4e0d\u540c\u7684Jupyter Notebook\u5bf9Python\u6709\u4e0d\u540c\u7684\u7248\u672c\u8981\u6c42\u3002\u6211\u4eec\u5b89\u88c5\u7684\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672cv6.5.2\u7684Jupyter Notebook\uff0c\u8981\u6c42Python\u7684\u6700\u4f4e\u7248\u672c\u4e3a3.6\u3002\u6ce8\u610f\u8fd9\u4e2aPython\u7684\u7248\u672c\uff0c\u4e0d\u540c\u4e8e\u5185\u6838\u7684Python\u7248\u672c\u3002\u5bf9\u4e8eJupyter\u5185\u6838\u6765\u8bf4\uff0c\u652f\u6301\u7684Python\u7248\u672c\u548cJupyter Notebook\u4f9d\u8d56\u7684Python\u7248\u672c\u6ca1\u6709\u5173\u7cfb\u3002<\/p>\n<p><strong>\u5728Linux\u7cfb\u7edf\u4e0b\u5b89\u88c5Jupyter Notebook<\/strong><\/p>\n<p>\u4f7f\u7528pip\u5b89\u88c5Jupyter notebook\u975e\u5e38\u7b80\u5355\u3002\u5982\u679c\u670d\u52a1\u5668\u540c\u65f6\u62e5\u6709Python2\u548cPython3\u7684pip\uff0c\u6ce8\u610f\u9700\u8981\u4f7f\u7528pip3\u6765\u66ff\u6362\u547d\u4ee4\u4e2d\u7684pip\u3002<\/p>\n<pre><code># \u66f4\u65b0pip\npip install --upgrade pip\n# \u5b89\u88c5jupyter\npip install jupyter\n# \u68c0\u67e5\u5b89\u88c5\u7684jupyter\njupyter --version\n\/\/\u8f93\u51fa notebook  : 6.5.2<\/code><\/pre>\n<h2><strong>4. \u914d\u7f6e\u548c\u542f\u52a8Jupyter<\/strong><\/h2>\n<p>Jupyter\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u542f\u52a8\u53c2\u6570\uff0c\u7528\u6765\u914d\u7f6eJupyter Server\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u542f\u52a8Jupyter\u670d\u52a1\u65f6\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u7684\u65b9\u5f0f\u914d\u7f6e\u5f53\u524d\u542f\u52a8\u7684\u670d\u52a1\uff0c\u4f46\u66f4\u666e\u904d\u7684\u65b9\u5f0f\u662f\u4f7f\u7528Jupyter\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<pre><code># \u751f\u6210\u914d\u7f6e\u6587\u4ef6\njupyter notebook --generate-config\n\/\/ \u9ed8\u8ba4\u751f\u6210\u7684\u914d\u7f6e\u6587\u4ef6\u4f4d\u7f6e\uff1a\n\/root\/.jupyter\/jupyter_notebook_config.py\n\n# \u4fee\u6539Jupyter\u914d\u7f6e\u6587\u4ef6...\n\n# \u542f\u52a8jupyter\njupyter notebook<\/code><\/pre>\n<p>Jupyter\u76f4\u63a5\u4f7f\u7528\u4e00\u4e2aPython\u6587\u4ef6\u6765\u914d\u7f6eJupyter\u670d\u52a1\uff0c\u6240\u6709\u7684\u914d\u7f6e\u9879\u5747\u901a\u8fc7Python\u4ee3\u7801\u6765\u5b8c\u6210\u3002\u5e38\u7528\u7684\u914d\u7f6e\u9879\u53ca\u5176\u8bf4\u660e\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u540d\u79f0<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>c.NotebookApp.allow_root<\/td>\n<td>False<\/td>\n<td>\u4e3a\u4e86\u5b89\u5168\uff0cJupyter\u9ed8\u8ba4\u4e0d\u5141\u8bb8\u4f7f\u7528root\u7528\u6237\u542f\u52a8\u3002\u5982\u679c\u9700\u8981\u4ee5root\u7528\u6237\u7684\u8eab\u4efd\u542f\u52a8Jupyter\uff0c\u9700\u8981\u5f00\u542f\u6b64\u8bbe\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.allow_origin<\/td>\n<td>&#8221;<\/td>\n<td>\u5f53\u9700\u8981Jupyter\u5185\u5d4c\u5230iframe\u65f6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u201c*\u201c\u6765\u907f\u514d\u8de8origin\u7684\u9650\u5236<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.ip<\/td>\n<td>localhost<\/td>\n<td>\u5f53\u9700\u8981\u901a\u8fc7\u5916\u7f51\u5730\u5740\u6765\u8bbf\u95eeJupyter\u670d\u52a1\u65f6\uff0c\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u6709\u6548\u7684\u670d\u52a1\u5668IP\u5730\u5740\u3002<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.port<\/td>\n<td>8888<\/td>\n<td>Jupyter server\u5bf9\u5916\u670d\u52a1\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.notebook_dir<\/td>\n<td>\/<\/td>\n<td>Jupyter\u7684\u5de5\u4f5c\u7a7a\u95f4\uff0c\u9ed8\u8ba4\u53ef\u4ee5\u8bbf\u95ee\u670d\u52a1\u5668\u4e0a\u5f53\u524d\u7528\u6237\u7684\u6240\u6709\u6587\u4ef6\u7cfb\u7edf<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.open_browser<\/td>\n<td>True<\/td>\n<td>\u542f\u52a8\u670d\u52a1\u540e\u662f\u5426\u7acb\u5373\u901a\u8fc7\u6d4f\u89c8\u5668\u6253\u5f00\u670d\u52a1\u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.default_url<\/td>\n<td>\/tree<\/td>\n<td>Jupyter\u670d\u52a1\u7684\u9ed8\u8ba4\u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.extra_static_paths<\/td>\n<td>[]<\/td>\n<td>\u6269\u5c55\u9759\u6001\u6587\u4ef6\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.extra_template_paths<\/td>\n<td>[]<\/td>\n<td>\u6269\u5c55\u6a21\u677f\u6587\u4ef6\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>c.KernelSpecManager.allowed_kernelspecs<\/td>\n<td>set()<\/td>\n<td>\u9ed8\u8ba4\u5141\u8bb8\u4f7f\u7528\u6240\u6709\u7684kernel<\/td>\n<\/tr>\n<tr>\n<td>c.NotebookApp.nbserver_extensions<\/td>\n<td>{}<\/td>\n<td>\u5141\u8bb8\u52a0\u8f7d\u7684Jupyter Server\u6269\u5c55<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>5. \u4f7f\u7528Jupyter<\/h2>\n<h3>5.1. \u521b\u5efaNotebook<\/h3>\n<p>\u542f\u52a8Jupyter \u540e\uff0c\u5728\u6d4f\u89c8\u5668\u5185\u8f93\u5165 http:\/\/\u670d\u52a1\u5668\u5730\u5740:\u7aef\u53e3\/\uff0cJupyter\u4f1a\u9ed8\u8ba4\u91cd\u5b9a\u5411\u5230.default_url\u6307\u5b9a\u7684\u5de5\u4f5c\u533a\u76ee\u5f55\u6811\u5730\u5740\uff0c\u9ed8\u8ba4\u662f\u5de5\u4f5c\u533a\u76ee\u5f55\u6811\u7684\u754c\u9762\u3002<\/p>\n<p>\u5982\u679c\u5728\u8bbf\u95ee\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u4e86\u9ed8\u8ba4\u7684token\u4f5c\u4e3a\u5176\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u90a3\u4e48\u5728\u9996\u6b21\u6253\u5f00\u65f6\uff0c\u9700\u8981\u8f93\u5165Jupyter Notebook\u7684token\u503c\uff0c\u8fd9\u4e2a\u503c\u53ef\u4ee5\u5728\u542f\u52a8Jupyter\u65f6\u7684\u63a7\u5236\u53f0\u8f93\u51fa\u4e2d\u627e\u5230\uff0c\u6216\u8005\u4f7f\u7528Jupyter\u547d\u4ee4\u6765\u67e5\u8be2<\/p>\n<pre><code># \u67e5\u8be2\u8fd0\u884c\u7684jupyter notebook\njupyter notebook list\n\/\/\u8fd4\u56de\u7ed3\u679c\u4e2d\u5305\u542b\u4e86http:\/\/x.x.x.x:8899?token=ABC \u7684\u4fe1\u606f\uff0c\u5176\u4e2d\u7684ABC\u5c31\u662f\u6211\u4eec\u9700\u8981\u7684token<\/code><\/pre>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228518\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe3 Jupter Notebook\u7684\u9ed8\u8ba4\u5de5\u4f5c\u533a\u76ee\u5f55\u6811\u9875\u9762<\/p>\n<p>Jupyter Notebook\u901a\u8fc7Jupyter Server\u63d0\u4f9b\u57fa\u4e8eWeb\u7684\u5e73\u53f0\u65e0\u5173\u7684\u5de5\u4f5c\u65b9\u5f0f\uff0c\u8fd9\u4f7f\u5f97\u8de8\u5e73\u53f0\u5f00\u53d1\u548c\u534f\u4f5c\uff0c\u4ee3\u7801\u5206\u4eab\u7b49\u80fd\u529b\u53d8\u5f97\u6bd4\u4f20\u7edfIDE\u66f4\u52a0\u5bb9\u6613\u3002<\/p>\n<p>\u5728Jupyter \u5de5\u4f5c\u533a\u7ba1\u7406\u754c\u9762\uff0c\u7528\u6237\u53ef\u4ee5\u7075\u6d3b\u5730\u4ee5\u7c7b\u4f3c\u6587\u4ef6\u7cfb\u7edf\u7684\u65b9\u5f0f\u7ba1\u7406\u5de5\u4f5c\u533a\u7684\u6570\u636e\u3002\u53ef\u4ee5\u521b\u5efa\u6587\u4ef6\u548c\u6587\u4ef6\u5939\uff0c\u7f16\u8f91\u6587\u4ef6\u548c\u6587\u4ef6\u5939\uff0c\u53ef\u4ee5\u4e0a\u4f20\u548c\u4e0b\u8f7d\u6587\u4ef6\u3002\u901a\u8fc7\u9009\u62e9\u4e00\u4e2aJupyter\u5185\u6838\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2aNotebook\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228519\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe4 \u901a\u8fc7Jupyter\u5185\u6838\u521b\u5efa\u4e00\u4e2aNotebook<\/p>\n<h3><strong>5.2. \u4f7f\u7528Notebook<\/strong><\/h3>\n<p>\u4f7f\u7528Python3\u5185\u6838\u521b\u5efa\u4e00\u4e2aNotebook\u540e\uff0c\u6211\u4eec\u5f97\u5230\u4e00\u4e2axxx.ipynb\uff08IPython Notebook\uff09\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u662f\u4e00\u4e2ajson\u683c\u5f0f\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u6211\u4eec\u5728Notebook\u4e2d\u7f16\u5199\u7684\u4ee3\u7801\u548c\u6587\u672c\u5185\u5bb9\uff0c\u4e5f\u5305\u542b\u4e86\u754c\u9762\u4e0a\u6ca1\u6709\u663e\u793a\u7684\u5143\u6570\u636e\u4fe1\u606f\u3002\u901a\u8fc7\u5728\u5de5\u4f5c\u533a\u76ee\u5f55\u754c\u9762\u9009\u62e9\u4e00\u4e2anotebook\u6587\u4ef6\uff0c\u70b9\u51fb\u7f16\u8f91\uff0c\u6211\u4eec\u53ef\u4ee5\u67e5\u770b\u5230ipynb\u6587\u4ef6\u7684\u539f\u59cb\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228520\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe5 ipynb\u6587\u4ef6\u7684\u539f\u59cb\u5185\u5bb9<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u50cf\u4f7f\u7528\u5176\u5b83IDE\u7c7b\u4f3c\u7684\u65b9\u5f0f\u6765\u4f7f\u7528Notebook\uff0c\u5728\u4f7f\u7528Notebook\u4e0a\uff0c\u6211\u4eec\u4e3b\u8981\u5173\u6ce8\u4e0bJupyter\u5185\u6838\u548c\u5355\u5143\u683c\u3002<\/p>\n<p>\u5185\u6838\u662f\u6267\u884c\u5355\u5143\u683c\u4ee3\u7801\u7684\u6838\u5fc3\u8fdb\u7a0b\uff0c\u4e0d\u540c\u7684\u5185\u6838\uff0c\u51b3\u5b9a\u4e86\u6211\u4eec\u5728\u5355\u5143\u683c\u4e2d\u80fd\u591f\u7f16\u5199\u54ea\u4e9b\u8bed\u8a00\u7684\u4ee3\u7801\uff0c\u4ee5\u53ca\u5bf9\u5e94\u4e86\u6307\u5b9a\u7684\u7f16\u7a0b\u8bed\u8a00\u7684\u54ea\u4e2a\u7248\u672c\u7b49\u4fe1\u606f\u3002<\/p>\n<p>\u5355\u5143\u683c\u662f\u6574\u4e2aNotebook\u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\uff0c\u6211\u4eec\u7f16\u5199\u7684\u4ee3\u7801\u548c\u6587\u672c\uff0c\u901a\u8fc7\u4e00\u4e9b\u5217Notebook\u5355\u5143\u683c\u6765\u7ec4\u6210\u3002Notebook\u63d0\u4f9b\u4e86Code\uff0cMarkdown, Raw NBConvert, Heading\u56db\u79cd\u7c7b\u578b\u7684\u5355\u5143\u683c\u3002<\/p>\n<p>\u2022Code\u5355\u5143\u683c\u3002\u7528\u6765\u7f16\u5199\u5185\u6838\u6307\u5b9a\u8bed\u8a00\u7684\u7a0b\u5e8f\u4ee3\u7801<\/p>\n<p>\u2022Markdown\u5355\u5143\u683c\u3002\u4f7f\u7528Markdown\u7f16\u8f91\u5668\u7684\u8bed\u6cd5\u6765\u7f16\u8f91\u5bcc\u6587\u672c<\/p>\n<p>\u2022Raw NBConvert\u5355\u5143\u683c\u3002\u539f\u59cb\u7684\u6587\u672c\uff0c\u4e0d\u4f1a\u88ab\u5f53\u4f5c\u4ee3\u7801\u6216markdown\u88ab\u89e3\u91ca\u6267\u884c<\/p>\n<p>\u2022Heading\u5355\u5143\u683c\u3002Heading\u662fMardown\u7684\u4e00\u4e2a\u5b50\u96c6\uff0c\u5bf9\u5e94\u4e86Markdown\u4e2d\u7684\u6807\u9898\u7f16\u5199\u8bed\u6cd5<\/p>\n<p>Jupyter Notebook\u4f7f\u7528\u4e86\u673a\u5668\u5b66\u4e60\u4e2d\u68c0\u67e5\u70b9\u7684\u6982\u5ff5\uff0c\u5728\u6211\u4eec\u4fee\u6539Notebook\u7684\u8fc7\u7a0b\u4e2d\uff0cJupyter\u4f1a\u81ea\u52a8\u4fdd\u5b58\u6211\u4eec\u7684\u4fee\u6539\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u3010\u6587\u4ef6\u3011-&gt;\u3010\u4fdd\u5b58\u3011\u6765\u624b\u52a8\u4fdd\u5b58\u68c0\u67e5\u70b9\u3002\u68c0\u67e5\u70b9\u6587\u4ef6\u5305\u542b\u4e86\u6211\u4eec\u7f16\u5199\u7684Notebook\u5185\u5bb9\uff0c\u4ee5\u53ca\u6267\u884c\u4ee3\u7801\u5355\u5143\u683c\u4e4b\u540e\u7684\u8f93\u51fa\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u5de5\u4f5c\u7a7a\u95f4\u7684\u201c.ipynb_checkpoints\u201d\u6587\u4ef6\u5939\u4e0b\uff0c\u627e\u5230\u8fd9\u4e9b\u68c0\u67e5\u70b9\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228521\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe6 \u4f7f\u7528Jupyter\u5355\u5143\u683c\u6765\u7f16\u5199\u4ea4\u4e92\u5f0f\u4ee3\u7801<\/p>\n<h3><strong>5.3. \u5206\u4eabNotebook<\/strong><\/h3>\n<p>\u76f8\u8f83\u4e8e\u4f7f\u7528\u4f20\u7edf\u7684IDE\u7f16\u5199\u7684\u4ee3\u7801\uff0c\u57fa\u4e8eWeb\u670d\u52a1\u7684Jupyter Notebook\u5728\u4ee3\u7801\u5206\u4eab\u4e0a\u62e5\u6709\u7740\u5929\u7136\u7684\u4f18\u52bf\u3002<\/p>\n<p>\u5728Jupyter Notebook\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\u5206\u4eab\u6211\u4eec\u521b\u4f5c\u7684nootbook\u3002<\/p>\n<ol>\n<li>\u4ea4\u4e92\u5f0fNotebook\u6587\u6863<\/li>\n<\/ol>\n<p>\u4f20\u7edf\u7684\u6280\u672f\u6587\u6863\u6216\u8005\u8bf4\u660e\u4e66\uff0c\u901a\u8fc7\u9759\u6001\u7684\u6587\u672c\uff0c\u914d\u5408\u56fe\u7247\u548c\u89c6\u9891\uff0c\u6765\u63cf\u8ff0\u548c\u8bb2\u89e3\u7279\u5b9a\u7684\u6280\u672f\u6216\u529f\u80fd\u3002\u6709\u4e86Jupyter Notebook\u540e\uff0c\u6211\u4eec\u4ecd\u7136\u53ef\u4ee5\u4f7f\u7528Notebook\u6765\u7f16\u5199\u7c7b\u4f3c\u4f20\u7edf\u7684\u6280\u672f\u6587\u6863\u3002\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u52a0\u5165\u66f4\u751f\u52a8\u7684\u4ee3\u7801\u4ea4\u4e92\u5355\u5143\u683c\uff0c\u7528\u6237\u901a\u8fc7\u67e5\u770b\u6587\u6863\u8bf4\u660e\uff0c\u5e76\u4e0e\u6587\u6863\u4e2d\u63d0\u4f9b\u7684\u4ee3\u7801\u8fdb\u884c\u4e92\u52a8\uff0c\u53ef\u4ee5\u66f4\u751f\u52a8\u5730\u4ecb\u7ecd\u4ea7\u54c1\u4e2d\u7684\u529f\u80fd\u548c\u6280\u672f\u3002\u6bcf\u4e2aJupyter Notebook\u7684ipynb\u6587\u4ef6\uff0c\u90fd\u5bf9\u5e94\u4e86\u4e00\u4e2a\u72ec\u7acb\u7684\u8bbf\u95ee\u5730\u5740\uff1a <a href=\"https:\/\/link.segmentfault.com\/?enc=jnhHbGA02rejJ7cqloii4Q%3D%3D.QSxUCsSjV4Fi0GU5AbYO6tjX0wmkErMBaw6Kx7x%2FzE%2B%2BPTGRLdAZshrqZiK9XEZG\" rel=\"nofollow\">http:\/\/x.x.x.x:8899\/notebooks&#8230;<\/a> ,\u901a\u8fc7\u5206\u4eab\u6b64\u6587\u4ef6\u7684\u5730\u5740\uff0c\u5176\u4ed6\u7528\u6237\u53ef\u4ee5\u65b9\u4fbf\u5730\u4f7f\u7528\u5305\u542b\u4e86\u5bcc\u6587\u672c\u548c\u53ef\u6267\u884c\u7684\u4ee3\u7801\u7684\u4ea4\u4e92\u5f0fNotebook\u6587\u6863\u3002<\/p>\n<ol start=\"2\">\n<li>\u79bb\u7ebfNotebook\u6587\u6863<\/li>\n<\/ol>\n<p>\u6211\u4eec\u901a\u8fc7\u9010\u6b65\u6267\u884c\u6587\u6863\u4e2d\u7684\u6240\u6709\u5355\u5143\u683c\uff0c\u5f97\u5230\u4e00\u4e2a\u5305\u542b\u4e86\u6211\u4eec\u7f16\u5199\u7684\u8bf4\u660e\u548c\u4ee3\u7801\uff0c\u4ee5\u53ca\u4ee3\u7801\u6267\u884c\u7684\u8f93\u51fa\u7ed3\u679c\u7684\u5b8c\u6574\u6587\u6863\u3002\u4e4b\u540e\u70b9\u51fb\u3010\u6587\u4ef6\u3011-&gt; \u3010\u53e6\u5b58\u4e3a\u3011\uff0c\u9009\u62e9\u4e00\u79cd\u5408\u9002\u7684\u6587\u4ef6\u683c\u5f0f\u3002\u6211\u4eec\u53ef\u4ee5\u628a\u6587\u6863\u5bfc\u51fa\u4e3a\u4e00\u4efd\u9759\u6001\u6587\u4ef6\uff0c\u901a\u8fc7\u5171\u4eab\u6b64\u9759\u6001\u6587\u4ef6\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86Notebook\u6587\u6863\u7684\u79bb\u7ebf\u5206\u4eab\u3002<\/p>\n<h3><strong>5.4. \u9b54\u6cd5\u51fd\u6570<\/strong><\/h3>\n<p>Jupyter Notebook\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5217\u9b54\u6cd5\u51fd\u6570\u6765\u589e\u5f3aJupyter Code\u5355\u5143\u683c\u7684\u529f\u80fd\uff0c\u901a\u8fc7\u9b54\u6cd5\u51fd\u6570\uff0c\u6211\u4eec\u80fd\u591f\u6267\u884cjavascript\u811a\u672c\uff0chtml\u4ee3\u7801\uff0c\u8fd0\u884c\u53e6\u4e00\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\u7b49\u8bb8\u591a\u989d\u5916\u7684\u529f\u80fd\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5728Jupyter\u4ee3\u7801\u5355\u5143\u683c\u4e2d\u4f7f\u7528 %lsmagic\u547d\u4ee4\u6765\u67e5\u770b\u6240\u6709\u7684\u9b54\u6cd5\u51fd\u6570\uff0c\u5982\u679c\u8981\u9605\u8bfb\u8be6\u7ec6\u7684\u9b54\u6cd5\u51fd\u6570\u7684\u4f7f\u7528\u8bf4\u660e\uff0c\u53ef\u4ee5\u53c2\u8003\uff1a <a href=\"https:\/\/link.segmentfault.com\/?enc=jrPuaql7OGJh8SVKnNviCQ%3D%3D.yboHa4m%2FT546FMfxh87vAaO4aURz24hshcoNHbZQa43BpXaH0FvzzyeAZ%2BsOT%2BISy9JVOkzxJqRo4PB%2Bf7l3bMjFNWin%2BVQtpRDFmsaMOO4%3D\" rel=\"nofollow\">https:\/\/ipython.readthedocs.i&#8230;<\/a><\/p>\n<p>\u9b54\u6cd5\u51fd\u6570\u5206\u4e3a\u884c\u9b54\u6cd5\u51fd\u6570\uff0c\u5355\u5143\u683c\u9b54\u6cd5\u51fd\u6570\u548c\u4f1a\u8bdd\u9b54\u6cd5\u51fd\u6570\u3002\u987e\u540d\u601d\u4e49\uff0c\u884c\u9b54\u6cd5\u51fd\u6570\u53ea\u5bf9\u5f53\u524d\u884c\u8d77\u4f5c\u7528\uff0c\u800c\u5355\u5143\u683c\u9b54\u6cd5\u51fd\u6570\u5219\u4f5c\u7528\u4e8e\u6574\u4e2a\u5355\u5143\u683c\uff0c\u4f1a\u8bdd\u9b54\u6cd5\u51fd\u6570\u5219\u4f5c\u7528\u4e8e\u6574\u4e2a\u4f1a\u8bdd\u671f\u95f4\u3002<\/p>\n<p>\u4e00\u4e9b\u5e38\u7528\u7684\u9b54\u6cd5\u51fd\u6570\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6307\u4ee4<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>%matplotlib<\/td>\n<td>\u8bbe\u7f6ematplot\u7ed8\u56fe\u7684\u663e\u793a\u6a21\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>%%javascript<\/td>\n<td>\u5355\u5143\u683c\u5185\u7684\u4ee3\u7801\u88ab\u8bc6\u522b\u4e3ajavascript\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td>%%html<\/td>\n<td>\u5355\u5143\u683c\u5185\u7684\u4ee3\u7801\u88ab\u8bc6\u522b\u4e3ahtml\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td>%run<\/td>\n<td>\u6267\u884c\u5916\u90e8\u811a\u672c\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>%pwd<\/td>\n<td>\u83b7\u53d6\u5f53\u524d\u5de5\u4f5c\u7684\u76ee\u5f55\u4f4d\u7f6e\uff08\u975e\u5de5\u4f5c\u7a7a\u95f4\u76ee\u5f55\u4f4d\u7f6e\uff09<\/td>\n<\/tr>\n<tr>\n<td>%writefile<\/td>\n<td>\u4ee5\u6587\u4ef6\u5f62\u5f0f\u4fdd\u5b58\u5f53\u524d\u5355\u5143\u683c\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td>%timeit<\/td>\n<td>\u83b7\u53d6\u672c\u884c\u4ee3\u7801\u7684\u6267\u884c\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>%debug<\/td>\n<td>\u6fc0\u6d3b\u8c03\u8bd5\u6a21\u5f0f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><strong>6. \u7ba1\u7406Jupyter<\/strong><\/h2>\n<h3><strong>6.1. \u591a\u8bed\u8a00<\/strong><\/h3>\n<p>Jupyter Notebook\u4f7f\u7528i18n\u76ee\u5f55\u4e0b\u7684\u8d44\u6e90\u6765\u8fdb\u884c\u591a\u8bed\u8a00\u7ffb\u8bd1\u3002\u5728Jupyter Notebook\u542f\u52a8\u65f6\uff0c\u4f1a\u52a0\u8f7di18n\u76ee\u5f55\u4e0b\u7684\u591a\u8bed\u8a00\u8d44\u6e90\u3002\u4e4b\u540e\u6839\u636ehttp\u8bf7\u6c42\u6307\u5b9a\u7684\u8bed\u8a00\uff0c\u4e3a\u54cd\u5e94\u6570\u636e\u63d0\u4f9b\u5bf9\u5e94\u7684\u591a\u8bed\u8a00\u7ffb\u8bd1\u3002\u5982\u679c\u6ca1\u6709\u5bf9\u5e94\u7684\u7ffb\u8bd1\uff0c\u5219\u4fdd\u7559\u539f\u59cb\u7684\u591a\u8bed\u8a00\u6807\u7b7e\u503c\uff08\u82f1\u6587\uff09\u3002\u5982\u679c\u8c03\u6574\u4e86\u591a\u8bed\u8a00\u7ffb\u8bd1\uff0c\u9700\u8981\u91cd\u65b0\u542f\u52a8Jupyter Notebook\u624d\u80fd\u4f7f\u7528\u65b0\u7684\u8bed\u8a00\u5305\u3002<\/p>\n<p>Jupyter Notebook\u7684\u7ffb\u8bd1\u8d44\u6e90\u4e3b\u8981\u5206\u5e03\u5728\u4e09\u4e2apo\u6587\u4ef6\u4e2d\uff1a<\/p>\n<p>\u2022nbjs.po &#8211; js\u6587\u4ef6\u4e2d\u7684\u591a\u8bed\u8a00\u6570\u636e<\/p>\n<p>\u2022nbui.po &#8211; UI\u754c\u9762\u4e2d\u7684\u591a\u8bed\u8a00\u6570\u636e<\/p>\n<p>\u2022notebook.po &#8211; notebook\u4e2d\u7684\u591a\u8bed\u8a00\u6570\u636e<\/p>\n<p>\u539f\u59cb\u7684po\u6587\u4ef6\uff0c\u9700\u8981\u901a\u8fc7pybabel\u5de5\u5177\uff0c\u628apo\u6587\u4ef6\u7f16\u8bd1\u6210mo\u6587\u4ef6\uff0c\u4e4b\u540e\u90e8\u7f72\u5728$notebook\/i18n\/${LANG}\/LC_MESSAGES\/\u76ee\u5f55\u4e0b\uff08$notebook\u662fnotebook\u7684\u5b89\u88c5\u76ee\u5f55\uff09\uff0c\u624d\u80fd\u5728Jupyter Notebook\u4e2d\u4f5c\u4e3a\u591a\u8bed\u8a00\u7684\u8d44\u6e90\u5305\u6765\u4f7f\u7528\u3002<\/p>\n<pre><code># \u4f7f\u7528pybabel\u7f16\u8bd1\u591a\u8bed\u8a00po\u6587\u4ef6\npybabel compile -D notebook -f -l ${LANG} -i ${LANG}\/LC_MESSAGES\/notebook.po -o ${LANG}\/LC_MESSAGES\/notebook.mo\npybabel compile -D nbui -f -l ${LANG} -i ${LANG}\/LC_MESSAGES\/nbui.po -o ${LANG}\/LC_MESSAGES\/nbui.mo\npybabel compile -D nbjs -f -l ${LANG} -i ${LANG}\/LC_MESSAGES\/nbjs.po -o ${LANG}\/LC_MESSAGES\/nbjs.mo<\/code><\/pre>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228522\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe7 \u4f7f\u7528\u4e86\u4e2d\u6587\u8bed\u8a00\u5305\u540e\u7684\u4e2d\u6587Notebook\u754c\u9762<\/p>\n<h3><strong>6.2. \u5185\u6838\u7ba1\u7406<\/strong><\/h3>\n<p>\u5185\u6838\uff08kernel\uff09\u662f\u72ec\u7acb\u4e8ejupyter\u670d\u52a1\u548c\u754c\u9762\u4e4b\u5916\u7684\u7528\u6765\u8fd0\u884cJupyter\u4ee3\u7801\u5355\u5143\u683c\u7684\u8fdb\u7a0b\uff0cJupyter\u9ed8\u8ba4\u63d0\u4f9b\u4e86ipykernel\u5185\u6838\u6765\u652f\u6301Python\u5f00\u53d1\u8bed\u8a00\u3002Jupyter\u793e\u533a\u63d0\u4f9b\u4e86jupyterC, IJava\uff0cxeus-cling, xeus-sql\u7b49\u4f17\u591a\u5176\u5b83\u7f16\u7a0b\u8bed\u8a00\u7684\u5185\u6838\uff0c\u7528\u6765\u652f\u6301C\/C++, Java, SQL\u7b49\u7f16\u7a0b\u8bed\u8a00\u3002<\/p>\n<p>ipykernel\u9ed8\u8ba4\u4f7f\u7528\u7cfb\u7edf\u73af\u5883\u4e0b\u7684Python\u6765\u63d0\u4f9b\u670d\u52a1\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528ipykernel\u5b89\u88c5\u591a\u4e2aPython kernel\u6765\u63d0\u4f9bPython2.x, Python3.x\u7b49\u591a\u4e2aPython\u5185\u6838\u73af\u5883\u3002<\/p>\n<p>\u5b89\u88c5kernel\u540e\uff0ckernel\u7684\u4fe1\u606f\u88ab\u4fdd\u5b58\u5728kernel.json\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 \/usr\/local\/share\/jupyter\/kernels \u76ee\u5f55\uff0c\u627e\u5230Jupyter\u5b89\u88c5\u7684\u6240\u6709kernel\u4ee5\u53ca\u5bf9\u5e94\u7684kernel.json\u6587\u4ef6\u3002<\/p>\n<p>kernel\u53ef\u4ee5\u76f4\u63a5\u7ee7\u627f\u81ea\u5b89\u88c5kernel\u7684Python\u6307\u4ee4\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528Python\u865a\u62df\u73af\u5883\u3002<\/p>\n<pre><code># 1.\u76f4\u63a5\u7ee7\u627f\u81eaPython\u6307\u4ee4\u7684kernel\u5b89\u88c5\n# \u5b89\u88c5ipykernel\npip install ipykernel\n# \u5b89\u88c5kernel\npython -m ipykernel install --name tensorflow2 --display-name &quot;tensorflow2&quot;\n\n# 2. \u5728Python\u865a\u62df\u73af\u5883\u4e0b\u7684kernel\u5b89\u88c5\n# \u6fc0\u6d3b\u865a\u62df\u73af\u5883\nsource activate myenv\n# \u5b89\u88c5ipykernel\npip install ipykernel\n# \u5b89\u88c5kernel\npython -m ipykernel install --name myenv --display-name &quot;Python3 (myenv)&quot;<\/code><\/pre>\n<p>\u5982\u679c\u9700\u8981\u67e5\u770b\u5f53\u524d\u7684kernel\u5217\u8868\uff0c\u4ee5\u53ca\u5220\u9664\u5df2\u7ecf\u5b89\u88c5\u7684kernel\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684Jupyter\u547d\u4ee4\uff1a<\/p>\n<pre><code># \u67e5\u770b\u5df2\u7ecf\u5b89\u88c5\u7684kernel\u5217\u8868\njupyter kernelspec list\n# \u5220\u9664\u5217\u8868\u4e2d\u6307\u5b9a\u7684kernel\njupyter kernelspec remove kernelname<\/code><\/pre>\n<h3>6.3. REST API<\/h3>\n<p>Jupyter\u63d0\u4f9b\u4e86REST API\u63a5\u53e3\u6765\u548cJupyter server\u8fdb\u884c\u4ea4\u4e92\u3002\u501f\u52a9REST API\u7684\u80fd\u529b\uff0c\u6211\u4eec\u53ef\u4ee5\u4ee5\u7f16\u7a0b\u7684\u65b9\u5f0f\u548cJupyter Server\u8fdb\u884c\u4ea4\u4e92\uff0c\u7075\u6d3b\u5730\u7ba1\u7406Jupyter Server\u3002\u53e6\u5916REST API\u4e3a\u73b0\u4ee3\u5316\u7684\u8f6f\u4ef6\u5f00\u53d1\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4f18\u79c0\u7684\u80fd\u529b\uff1a\u81ea\u52a8\u5316\u3002<\/p>\n<p>\u501f\u52a9Jupyter Notebook REST API\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d\uff0c\u68c0\u67e5\u70b9\u7ba1\u7406\uff0c\u4f1a\u8bdd\u7ba1\u7406\uff0c\u5185\u6838\u7ba1\u7406\uff0c\u7ec8\u7aef\u7ba1\u7406\u7b49\u4e00\u4e9b\u5217\u7ba1\u7406\u80fd\u529b\u3002\u5b8c\u6574\u7684Jupyter REST API\u63a5\u53e3\u5217\u8868\u53ef\u4ee5\u53c2\u8003\uff1a <a href=\"https:\/\/link.segmentfault.com\/?enc=J%2FTx7PQmHNjEzYwDIk3Y6A%3D%3D.t2%2BL1Id5f%2FJ0ic7PvcJ8WD%2FHJsRS0GGelwM8%2F1wLGjonqjV9tIg1ubJy9vuQnsOuDKMa1753KbDfrJD09or%2FLtBryPqS1WOghaeS9oHbz6w%3D\" rel=\"nofollow\">https:\/\/jupyter-server.readth&#8230;<\/a><\/p>\n<p>\u8981\u4f7f\u7528REST API\uff0c\u9700\u8981\u5728\u8bf7\u6c42\u4e2d\u643a\u5e26\u8ba4\u8bc1\u4fe1\u606f\u3002Jupyter\u652f\u6301\u76f4\u63a5\u628atoken\u4f5c\u4e3aquery string\u7684\u65b9\u5f0f\u6765\u8ba4\u8bc1\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6807\u51c6\u7684Http Authorization\u5934\u4fe1\u606f\u6765\u5b8c\u6210\u8ba4\u8bc1\u3002\u4f7f\u7528Authorization\u5934\u6765\u8ba4\u8bc1\u7684\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre><code>Authrozation: token 527a9f1430ccfed995ebcf15517583a2547c2469bc3c47a6<\/code><\/pre>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228523\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe8 \u4f7f\u7528Postman\u6765\u8c03\u7528Jupyter REST API\u63a5\u53e3<\/p>\n<h3><strong>6.4. \u5b89\u5168\u7ba1\u7406\u4e0e\u591a\u4eba\u534f\u4f5c<\/strong><\/h3>\n<p>Jupyter\u63d0\u4f9b\u4e86\u7075\u6d3b\u5f3a\u5927\u7684\u80fd\u529b\uff0c\u7528\u4ee5\u652f\u6301\u5728\u7ebf\u7684\u4ea4\u4e92\u5f0f\u6587\u6863\u548c\u4ee3\u7801\u7684\u7f16\u5199\u3002\u4f46Jupyter\u9879\u76ee\u81ea\u8eab\u6ca1\u6709\u63d0\u4f9b\u7cbe\u7ec6\u5316\u7684\u5b89\u5168\u7ba1\u7406\u4f53\u7cfb\uff0c\u7528\u4ee5\u652f\u6301\u591a\u7528\u6237\u4e0b\u7075\u6d3b\u5730\u4f7f\u7528Jupyter Notebook\u7684\u529f\u80fd\u3002\u5bf9\u4e8e\u6587\u4ef6\u5b89\u5168\uff0cJupyter\u4f9d\u8d56\u4e8e\u542f\u52a8\u670d\u52a1\u7684linux\u7528\u6237\uff0c\u5408\u7406\u5730\u914d\u7f6e\u542f\u52a8Jupyter\u7684\u7528\u6237\u7684\u6743\u9650\uff0c\u624d\u80fd\u4fdd\u8bc1\u4f7f\u7528Jupyter\u7684\u7528\u6237\uff0c\u4e0d\u4f1a\u5bf9\u7cfb\u7edf\u6216\u9879\u76ee\u9020\u6210\u7834\u574f\u3002Jupyter\u5de5\u4f5c\u7a7a\u95f4\u7684\u8bbe\u5b9a\uff0c\u4ec5\u8d77\u5230\u4e86\u65b9\u4fbfJupyter\u4f7f\u7528\u8005\u7ba1\u7406\u5fc5\u8981\u6587\u4ef6\u7684\u6613\u7528\u6027\uff0c\u4e0d\u80fd\u963b\u6321\u7528\u6237\u8bbf\u95ee\u548c\u7ba1\u7406\u5de5\u4f5c\u7a7a\u95f4\u5916\u7684\u6587\u4ef6\u7cfb\u7edf\u3002\u53e6\u5916\uff0c\u914d\u5408\u4f7f\u7528Python\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u9632\u6b62Jupyter Notebook\u63d0\u4f9b\u7684 pip install ,pip uninstall\u529f\u80fd\uff0c\u5bf9\u73b0\u6709\u9879\u76ee\u73af\u5883\u9020\u6210\u7834\u574f\u3002<\/p>\n<p>\u5728\u591a\u4eba\u534f\u4f5c\u65b9\u9762\uff0cJupyterHub\u9879\u76ee\u63d0\u4f9b\u4e86\u591a\u4eba\u534f\u4f5cJupyter Notebook\u548cJupyter lab\u5f00\u53d1\u7684\u80fd\u529b\u3002\u4f7f\u7528JupyterHub,\u4e0d\u540c\u804c\u80fd\u7684\u7528\u6237\u53ef\u4ee5\u5728\u81ea\u5df1\u72ec\u7acb\u7684\u7a7a\u95f4\u5185\u8fdb\u884cNotebook\u7684\u7f16\u5199\u5de5\u4f5c\uff0c\u4e0d\u540c\u7528\u6237\u95f4\u4e5f\u53ef\u4ee5\u65b9\u4fbf\u5730\u5206\u4eab\u5404\u81ea\u7684Notebook\u3002<\/p>\n<h2><strong>7. \u6269\u5c55Jupyter<\/strong><\/h2>\n<h3><strong>7.1. \u524d\u7aef\u6269\u5c55<\/strong><\/h3>\n<p>Jupyter Notebook\u524d\u7aef\u6269\u5c55(front end extension)\u662f\u4f7f\u7528Javascript\u8bed\u8a00\u7f16\u5199\u7684\u5f02\u6b65\u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u6765\u7ed8\u5236Jupyter\u754c\u9762\u7684\u4eea\u8868\u76d8\uff0cNotebook\uff0c\u5de5\u5177\u680f\u7b49\uff0c\u3002\u5b9a\u4e49\u4e00\u4e2a\u524d\u7aef\u6269\u5c55\u5fc5\u987b\u8981\u5b9e\u73b0\u4e00\u4e2aload_ipython_extension\u65b9\u6cd5\uff0c\u5f53\u524d\u7aef\u63a7\u4ef6\u88ab\u52a0\u8f7d\u65f6\uff0cJupyter client\u4f1a\u8c03\u7528load_ipython_extension\u65b9\u6cd5\u3002<\/p>\n<p>Jupyter Notebook\u524d\u7aef\u6269\u5c55\u80fd\u529b\u76ee\u524d\u8fd8\u4e0d\u662f\u4e00\u4e2a\u7a33\u5b9a\u7684\u7248\u672c\uff0c\u4e0d\u4fdd\u8bc1\u4ee3\u7801\u80fd\u591f\u5411\u540e\u517c\u5bb9\u3002Jupyter\u7684JS API\u76ee\u524d\u4e5f\u6ca1\u6709\u5b98\u65b9\u7684\u6587\u6863\uff0c\u9700\u8981\u901a\u8fc7\u6e90\u4ee3\u7801\u6216\u8005\u5b9e\u9645\u52a0\u8f7d\u7684JS\u6765\u67e5\u770bJupyter\u524d\u7aef\u811a\u672c\u7684\u6210\u5458\u548c\u65b9\u6cd5\u3002<\/p>\n<p>\u6211\u4eec\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u524d\u7aef\u6269\u5c55\u811a\u672c\uff0c\u5728jupyter\u524d\u7aef\u7684\u5de5\u5177\u6761\u4e2d\uff0c\u6dfb\u52a0\u4e00\u4e2a\u81ea\u5b9a\u4e49\u5de5\u5177\uff0c\u5f53\u70b9\u51fb\u81ea\u5b9a\u4e49\u5de5\u5177\u65f6\uff0c\u5f39\u51fa\u63d0\u793a\u4fe1\u606f\u3002<\/p>\n<pre><code>define([\n    'base\/js\/namespace'\n], function(\n    Jupyter\n) {\n    function load_ipython_extension() {\n\n        var handler = function () {\n            alert('\u6b22\u8fce\u4f7f\u7528\u524d\u7aef\u6269\u5c55!');\n        };\n\n        var action = {\n            icon: 'fa-comment-o',\n            help    : '\u524d\u7aef\u6269\u5c55',\n            help_index : 'zz',\n            handler : handler\n        };\n        var prefix = 'my_extension';\n        var action_name = 'show-alert';\n\n        var full_action_name = Jupyter.actions.register(action, action_name, prefix); \/\/ returns 'my_extension:show-alert'\n        Jupyter.toolbar.add_buttons_group([full_action_name]);\n    }\n\n    return {\n        load_ipython_extension: load_ipython_extension\n    };\n});<\/code><\/pre>\n<p>\u5b8c\u524d\u7aef\u6269\u5c55\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u628a\u811a\u672c\u4fdd\u5b58\u5230main.js\u6587\u4ef6\uff0c\u653e\u7f6e\u5728\/opt\/my_extension\u76ee\u5f55\u4e0b\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u4f7f\u7528jupyter nbextension\u5de5\u5177\u6765\u5b89\u88c5\u548c\u542f\u7528\u524d\u7aef\u6269\u5c55<\/p>\n<pre><code># \u5b89\u88c5\u524d\u7aef\u6269\u5c55\njupyter nbextension install \/opt\/my_extension\n# \u542f\u7528\u524d\u7aef\u6269\u5c55\njupyter nbextension enable my_extension\/main\n# \u7981\u7528\u524d\u7aef\u6269\u5c55\njupyter nbextension disable my_extension\/main\n# \u67e5\u770b\u524d\u7aef\u6269\u5c55\u5217\u8868\njupyter nbextension list\n# \u5378\u8f7d\u524d\u7aef\u6269\u5c55\njupyter nbextension uninstall my_extension<\/code><\/pre>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228524\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe9 \u5728Notebook\u5de5\u5177\u6761\u4e2d\u52a0\u5165\u7684\u524d\u7aef\u6269\u5c55<\/p>\n<h3><strong>7.2. \u670d\u52a1\u7aef\u6269\u5c55<\/strong><\/h3>\n<p>Jupyter\u670d\u52a1\u7aef\u6269\u5c55\uff08server extension\uff09\u662f\u4f7f\u7528Python\u8bed\u8a00\u7f16\u5199\u7684\u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u6765\u5904\u7406\u53d1\u9001\u5230Jupyter Server\u7684Http\u8bf7\u6c42\u3002\u4f7f\u7528Jupyter\u670d\u52a1\u7aef\u6269\u5c55\uff0c\u53ef\u4ee5\u66f4\u6539\u73b0\u6709Jupyter\u8bf7\u6c42\u7684\u6570\u636e\u548c\u884c\u4e3a\uff0c\u4e5f\u53ef\u4ee5\u4e3ajupyter Server\u5b9a\u4e49\u65b0\u7684\u670d\u52a1\u5904\u7406\u7a0b\u5e8f\u3002<\/p>\n<p>\u5b9a\u4e49\u4e00\u4e2a\u670d\u52a1\u7aef\u6269\u5c55\u6a21\u5757\u8981\u5b9e\u73b0\u4e00\u4e2aload_jupyter_server_extension\u65b9\u6cd5\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u7c7b\u578b\u4e3anotebook.notebookapp.NotebookApp\u7684\u53c2\u6570serverapp\uff0cserverapp\u7684\u8be6\u7ec6\u5c5e\u6027\u548c\u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7Jupyter Notebook\u6e90\u4ee3\u7801\u4e2d\u7684notebookapp.py\u6587\u4ef6\u6765\u67e5\u770b\u3002\u5f53\u670d\u52a1\u7aef\u6269\u5c55\u88ab\u52a0\u8f7d\u65f6\uff0cJupyter Server\u4f1a\u8c03\u7528load_jupyter_server_extension\u65b9\u6cd5\u3002\u5728load_jupyter_server_extension\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528serverapp\u7684web_app\u5c5e\u6027\u7684add_handlers\u65b9\u6cd5\u6765\u6ce8\u518c\u5904\u7406\u7a0b\u5e8f\uff0c\u7528\u6765\u5904\u7406\u7279\u5b9a\u7684\u670d\u52a1\u7aef\u8bf7\u6c42\u3002\u5904\u7406\u7a0b\u5e8f\u7c7b\u9700\u8981\u7ee7\u627f\u81eaJupyter\u7684IPythonHandler\u7c7b\u3002\u5728\u5904\u7406\u7a0b\u5e8f\u7684\u65b9\u6cd5\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Jupyter\u63d0\u4f9b\u7684@web.authenticated\u88c5\u9970\u5668\u6765\u4e3a\u65b9\u6cd5\u589e\u52a0\u8eab\u4efd\u8ba4\u8bc1\u4fdd\u62a4\u3002<\/p>\n<p>\u901a\u8fc7\u670d\u52a1\u7aef\u6269\u5c55\uff0c\u8fd8\u53ef\u4ee5\u4e0e\u524d\u7aef\u6269\u5c55\u8054\u52a8\uff0c\u5b9e\u73b0\u4e00\u4e2a\u529f\u80fd\u4e30\u5bcc\u7684Jupyter Notebook\u524d\u7aef\u63a7\u4ef6\u3002<\/p>\n<pre><code># \u5b9a\u4e49\u4e00\u4e2a\u5904\u7406\u7a0b\u5e8f\nfrom tornado import (\n    gen, web,\n)\nfrom notebook.base.handlers import IPythonHandler\n\nclass HelloWorldHandler(IPythonHandler):\n    @web.authenticated\n    @gen.coroutine\n    def get(self):\n        self.finish(f'Hello, world!')\n\n\n# \u5b9e\u73b0load_jupyter_server_extension\u65b9\u6cd5\u5e76\u6ce8\u518c\u5904\u7406\u7a0b\u5e8f\ndef load_jupyter_server_extension(serverapp):\n    handlers = [\n        ('\/myextension\/hello', HelloWorldHandler)\n    ]\n    serverapp.web_app.add_handlers('.*$', handlers)<\/code><\/pre>\n<p>\u5b8c\u6210\u670d\u52a1\u7aef\u6269\u5c55\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u628a\u4ee3\u7801\u4fdd\u5b58\u4e3a__init__.py\u6587\u4ef6\uff0c\u8981\u5728Jupyter Notebook\u4e2d\u4f7f\u7528\u5904\u7406\u7a0b\u5e8f\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u8fdb\u884c\u670d\u52a1\u7aef\u6269\u5c55\u7684\u5b89\u88c5\u548c\u542f\u7528\u3002\u4e0d\u540c\u4e8e\u524d\u7aef\u6269\u5c55\uff0c\u670d\u52a1\u7aef\u6269\u5c55\u4e0d\u80fd\u76f4\u63a5\u4f7f\u7528\u6307\u4ee4\u6765\u5b89\u88c5\uff0c\u9700\u8981\u6211\u4eec\u624b\u52a8\u7f16\u5199\u5b89\u88c5\u7a0b\u5e8f\u3002\u6b64\u5916\uff0cJupyter\u63d0\u4f9b\u4e86\u81ea\u52a8\u542f\u7528\u670d\u52a1\u7aef\u6269\u5c55\u548c\u524d\u7aef\u6269\u5c55\u7684\u65b9\u6cd5\uff0c\u9700\u8981\u6211\u4eec\u5728\u811a\u672c\u7684\u6839\u76ee\u5f55\u63d0\u4f9b\u542f\u7528\u6269\u5c55\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<pre><code>jupyter-config\/\n\u251c\u2500\u2500 jupyter_notebook_config.d\/\n\u2502   \u2514\u2500\u2500 my_server_extension.json\n\u2514\u2500\u2500 nbconfig\/\n    \u2514\u2500\u2500 notebook.d\/\n        \u2514\u2500\u2500 my_front_extension.json\n setup.py<\/code><\/pre>\n<p>\u52a0\u5165\u4e86\u81ea\u52a8\u542f\u7528\u6269\u5c55\u7684\u914d\u7f6e\uff0c\u6211\u4eec\u7684\u670d\u52a1\u7aef\u6269\u5c55\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre><code>hello-extension\/\n\u251c\u2500\u2500 __init__.py\njupyter-config\/\n\u251c\u2500\u2500 jupyter_notebook_config.d\/\n    \u2514\u2500\u2500 hello_extension.json<\/code><\/pre>\n<p>hello_extension.json\u6587\u4ef6\u7684\u5185\u5bb9\u4e3a\uff1a<\/p>\n<pre><code>{\n    &quot;ServerApp&quot;: {\n        &quot;jpserver_extensions&quot;: {\n            &quot;hello_extension&quot;: true\n        }\n    }\n}<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5b89\u88c5\u670d\u52a1\u7aef\u6269\u5c55\u7684\u4fe1\u606f\u4fdd\u5b58\u5728\/root\/.jupyter\/jupyter_notebook_config.json\u6587\u4ef6\u4e2d\u3002\u5728\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7jupyter serverextesion\u5de5\u5177\u6765\u80a1\u90a3\u91cc\u670d\u52a1\u7aef\u6269\u5c55<\/p>\n<pre><code># \u542f\u7528\u670d\u52a1\u7aef\u6269\u5c55\njupyter serverextension enable hello_extension\n# \u7981\u7528\u670d\u52a1\u7aef\u6269\u5c55\njupyter serverextension disable hello_extension\n\n# \u670d\u52a1\u7aef\u6269\u5c55\u76f4\u63a5\u5378\u8f7d\u7684\u65b9\u6cd5\uff0c\u9700\u8981\u6211\u4eec\u901a\u8fc7pip uninstall \u5378\u8f7d\u5b89\u88c5\u7a0b\u5e8f\uff0c\n# \u518d\u901a\u8fc7\u624b\u5de5\u4fee\u6539\/root\/.jupyter\/jupyter_notebook_config.json\u6587\u4ef6\u5220\u9664\u6269\u5c55\u4fe1\u606f\u6765\u5b8c\u6210\u5378\u8f7d<\/code><\/pre>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228525\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe10 \u5728\u6d4f\u89c8\u5668\u4e2d\u6d4b\u8bd5\u5b89\u88c5\u7684\u670d\u52a1\u7aef\u6269\u5c55\u7a0b\u5e8f<\/p>\n<h3><strong>7.3. \u754c\u9762\u5b9a\u5236<\/strong><\/h3>\n<p>Jupyter\u6ca1\u6709\u63d0\u4f9b\u6807\u51c6\u7684\u754c\u9762\u5b9a\u5236\u7684\u80fd\u529b\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u624b\u5de5\u8c03\u6574jupyter\u751f\u6210\u7684\u6a21\u677f\u89c6\u56fe\u6587\u4ef6\u548c\u6837\u5f0f\u6587\u4ef6\uff0c\u8fbe\u5230\u6574\u6761\u8c03\u6574jupyter notebook\u7684\u754c\u9762\u7684\u80fd\u529b\u3002<\/p>\n<p>Jupyter Notebook\u6a21\u677f\u6587\u4ef6\u7684\u4f4d\u7f6e\u4e3a\uff1a$notebook\/templates\uff0c\u6837\u5f0f\u548c\u811a\u672c\u5b9a\u5236\u63a8\u8350\u7684\u65b9\u6848\u662f\u4f7f\u7528~\/.jupyter\/custom\/custom.css\u548c~\/.jupyter\/custom\/custom.js\u6587\u4ef6\u3002\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u5728\u6b64\u57fa\u7840\u4e0a\u5bf9\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7extra_template_paths\u548cextra_static_paths\u6765\u5f15\u5165\u5176\u5b83\u4f4d\u7f6e\u7684\u6a21\u677f\u548c\u5176\u5b83\u9759\u6001\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228526\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe11 \u901a\u8fc7\u76f4\u63a5\u8c03\u6574\u6a21\u677f\u6587\u4ef6\u52a0\u5165\u7684\u754c\u9762\u5b9a\u5236\u6309\u94ae<\/p>\n<h3><strong>7.4. \u5c0f\u90e8\u4ef6<\/strong><\/h3>\n<p>\u5c0f\u90e8\u4ef6\uff08Widgets\uff09\u662fJupyter\u4ea4\u4e92\u5f0f\u53ef\u89c6\u5316\u6570\u636e\u5448\u73b0\u90e8\u4ef6\u3002Jupyter Widgets\u540c\u65f6\u5305\u542b\u4e86\u8bbf\u95ee\u540e\u7aef\u6570\u636e\u548c\u524d\u7aef\u5448\u73b0\u7684\u80fd\u529b\uff0c\u53ef\u4ee5\u7528\u4e8e\u5728Jupyter Notebook\u4e0a\u751f\u52a8\u5730\u5c55\u793a\u670d\u52a1\u7aef\u7684\u6570\u636e\u548c\u6570\u636e\u53d8\u5316\u3002<\/p>\n<p>\u5728v6.5.2\u7a33\u5b9a\u7248\u672c\u4e0a\uff0c\u6211\u4eec\u76ee\u524d\u53ea\u80fd\u4f7f\u7528\u7cfb\u7edf\u63d0\u4f9b\u7684\u5c0f\u90e8\u4ef6\uff0c\u8fd8\u4e0d\u80fd\u5f00\u53d1\u81ea\u5b9a\u4e49\u5c0f\u90e8\u4ef6\u3002\u5728Jupyter notebook7.x\u7248\u672c\u4e2d\uff0c\u5f00\u59cb\u63d0\u4f9b\u4e86\u5c0f\u90e8\u4ef6\u7684\u81ea\u5b9a\u4e49\u5f00\u53d1\u80fd\u529b\u3002<\/p>\n<pre><code># \u786e\u4fdd\u5b89\u88c5\u4e86ipywidgets\u548ctraitlets\npip install --upgrade traitlets\npip install --upgrade ipywidgets\n\n# \u5b89\u88c5\u548c\u542f\u7528\u5c0f\u90e8\u4ef6\njupyter nbextension install --py widgetsnbextension\njupyter nbextension enable --py widgetsnbextension<\/code><\/pre>\n<p>\u5728\u5b89\u88c5\u548c\u542f\u7528\u4e86\u5c0f\u90e8\u4ef6\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728notebook\u4e2d\u76f4\u63a5\u4f7f\u7528\u7cfb\u7edf\u63d0\u4f9b\u7684\u5c0f\u90e8\u4ef6\u3002<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043228527\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>\u56fe12 \u5728Notebook\u4e2d\u4f7f\u7528\u5c0f\u90e8\u4ef6<\/p>\n<p>\u5b8c\u6574\u7684\u5c0f\u90e8\u4ef6\u5217\u8868\u548c\u4f7f\u7528\u65b9\u5f0f\u53ef\u4ee5\u53c2\u8003\uff1a <a href=\"https:\/\/link.segmentfault.com\/?enc=WYh8bXAOt%2BxNYqy1%2BJYW3w%3D%3D.0WR%2FBoVjioTNc6ns14m2QubD0NzYvrVSoiBZh5wQVCs2ik9xEN%2FUrbOcbsUhcqGIc7N9BS28B4BC4NcZigNEiEfYEY5a0FEEHSPm7GOfpgs%3D\" rel=\"nofollow\">https:\/\/ipywidgets.readthedoc&#8230;<\/a><\/p>\n<h2><strong>8. \u603b\u7ed3<\/strong><\/h2>\n<p>Jupyter Notebook\u4ee5\u5176\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u7b80\u5355\u6613\u7528\uff0c\u5f3a\u5927\u7684\u4ea4\u4e92\u80fd\u529b\u548c\u6269\u5c55\u80fd\u529b\uff0c\u6210\u4e3a\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u5f00\u53d1\u4e2d\u7684\u795e\u5668\u3002\u76ee\u524d\uff0cJupyter Notebook\u652f\u6301\u8d85\u8fc740\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u88ab\u5e94\u7528\u4e8eGoogle Colab, Kubeflow, \u534e\u4e3a\u4e91\uff0ckaggle\u7b49\u591a\u4e2a\u77e5\u540d\u9879\u76ee\u4e2d\uff0c\u5927\u91cf\u673a\u5668\u5b66\u4e60\u548c\u6570\u636e\u79d1\u5b66\u7684\u8bba\u6587\u4e2d\u4f7f\u7528\u5230\u4e86Jupyter\u3002Jupyter\u5728\u6570\u636e\u53ef\u89c6\u5316\uff0c\u63d0\u5347\u5de5\u4f5c\u6548\u7387\uff0c\u6539\u5584\u7528\u6237\u4f53\u9a8c\u548c\u4e30\u5bcc\u6587\u6863\u529f\u80fd\u65b9\u9762\u663e\u73b0\u4e86\u5de8\u5927\u7684\u5a01\u529b\u3002\u9664\u6b64\u4e4b\u5916\uff0cJupyter\u8fd8\u63d0\u4f9b\u7684\u7075\u6d3b\u5f3a\u5927\u7684\u6269\u5c55\u80fd\u529b\uff0c\u66f4\u662f\u4e3aJupyter\u7684\u6df1\u5c42\u6b21\u4f7f\u7528\u63d0\u4f9b\u4e86\u66f4\u5e7f\u9614\u7684\u60f3\u8c61\u7a7a\u95f4\u3002\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5f00\u59cb\u63a5\u89e6Jupyter\uff0c\u90a3\u4e48\u5c31\u4ece\u73b0\u5728\u5f00\u59cb\u5427\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000043228514\">https:\/\/segmentfault.com\/a\/1190000043228514<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u4eac\u4e1c\u79d1\u6280\u9690\u79c1\u8ba1\u7b97\u4ea7\u54c1\u90e8 \u5b59\u6653\u519b 1. Jupyter Notebook\u4ecb\u7ecd \u56fe1 Jupter\u9879\u76ee\u6574\u4f53\u67b6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10007039","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10007039"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007039\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10007039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10007039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10007039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}