使用Jupyter Notebook编写技术文档

论坛 期权论坛     
选择匿名的用户   2021-5-30 11:17   37   0
<div class="blogpost-body" id="cnblogs_post_body">
<h2>1、jupyter Notebook的组成</h2>
<p>  这里它的组件及其工程构成,帮助大家更好的用好jupyter Notebook</p>
<h3>组件</h3>
<p>Jupyter Notebook结合了三个组件:</p>
<ul class="simple"><li><strong>笔记本Web应用程序</strong>:交互式Web应用程序,用于交互编写和运行代码以及编写笔记本文档。</li><li><strong>内核</strong>:笔记本Web应用程序启动的独立进程,它以给定语言运行用户代码,并将输出返回给笔记本Web应用程序。内核还处理诸如交互式小部件,选项卡完成和内省的计算。</li><li><strong>笔记本文档</strong>:自包含文档,其中包含笔记本Web应用程序中可见的所有内容的表示,包括计算的输入和输出,叙述性文本,方程式,图像以及对象的富媒体表示。每个笔记本文档都有自己的内核。</li></ul>
<h3>jupyter notebook的工程组件</h3>
<p>笔记本Web应用程序使用户能够:</p>
<ul class="simple"><li><strong>在浏览器中编辑代码</strong>,自动语法高亮,缩进和制表符完成/内省。</li><li><strong>从浏览器运行代码,将</strong>计算结果附加到生成它们的代码。</li><li>查看<strong>富媒体表示</strong>的计算结果,如HTML,LaTeX,PNG,SVG,PDF等。</li><li>创建并使用<strong>交互式JavaScript小部件</strong>,它将交互式用户界面控件和可视化绑定到反应式内核端计算。</li><li>使用 <a class="reference external" href="https://daringfireball.net/projects/markdown/">Markdown</a>标记语言撰写<strong>叙述性文字</strong>。</li><li>使用<strong>LaTeX语法在Markdown中</strong>包含<a class="reference external" href="https://www.mathjax.org/">MathJax</a>在浏览器中呈现的 数学公式。</li></ul>
<p>通过Jupyter的内核和消息体系结构,Notebook允许代码以各种不同的编程语言运行。对于用户打开的每个笔记本文档,Web应用程序启动一个运行该笔记本代码的内核。每个内核都能够以单一编程语言运行代码,并且有以下语言提供的内核:</p>
<ul class="simple"><li>Python(<a class="reference external" href="https://github.com/ipython/ipython">https://github.com/ipython/ipython</a>)</li><li>Julia (<a class="reference external" href="https://github.com/JuliaLang/IJulia.jl">https://github.com/JuliaLang/IJulia.jl</a>)</li><li>R (<a class="reference external" href="https://github.com/IRkernel/IRkernel">https://github.com/IRkernel/IRkernel</a>)</li><li>Ruby (<a class="reference external" href="https://github.com/minrk/iruby">https://github.com/minrk/iruby</a>)</li><li>Haskell (<a class="reference external" href="https://github.com/gibiansky/IHaskell">https://github.com/gibiansky/IHaskell</a>)</li><li>Scala (<a class="reference external" href="https://github.com/Bridgewater/scala-notebook">https://github.com/Bridgewater/scala-notebook</a>)</li><li>node.js (<a class="reference external" href="https://gist.github.com/Carreau/4279371">https://gist.github.com/Carreau/4279371</a>)</li><li>Go (<a class="reference external" href="https://github.com/takluyver/igo">https://github.com/takluyver/igo</a>)</li></ul>
<p>  在内部,笔记本文档是 <strong>&#96;JSON &lt;https://en.wikipedia.org/wiki/JSON&gt;&#96;__数据</strong>的<strong>二进制值&#96;base64 &lt;http://en.wikipedia.org/wiki/Base64&gt;&#96;__</strong>编码。这使得它们可以通过任何编程语言以编程方式<strong>读取和操作</strong>。因为JSON是一种文本格式,所以笔记本文件是版本控</p>
<p>制友好的。</p>
<p> </p>
<h2>2、创建新环境并导入kernel</h2>
<p>对于不是直接安装anaconda的用户来说,首先需要安装 ipykernel 模块</p>
<div class="cnblogs_Highlighter">
  <pre class="brush:bash;gutter:true;">pip install ipykernel
</pre>
</div>
<p> 然后用类似于</p>
<div class="cnblogs_Highlighter">
  <pre class="brush:bash;gutter:true;">conda create --name python34 python&#61;3.4
</pre>
</div>
<p>  的指令来创建新的环境,然后对环境进行配置及必要第三方包的安装即可创建一个新的环境。关于第三方包的管理和环境的配置,请看<a href="http://www.cnblogs.com/noticeable/p/9006861.html" id="cb_post_title_url">jupyter Notebook环境搭建</a>。</p>
<p>当然你也可以通过ananconda navigator来进行环境的管理:</p>
<p><img alt="" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-95b8cac37d54119dc58e2c91792820b0.png" style="margin-left:auto;"></p>
<p>环境创建完成后,打开Jupyter后,我们点击new,会发现只有一个kernel</p>
<p><img alt="" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-df7a03575070e115c1b2fcc794c3c616.png" style="margin-left:auto;"></p>
<p> 如果我们希望使用其他环境,需要导入其他环境到kernel中来。就需要用到以下命令:</p>
<p>1)查看jupyter notebook kernel指令</p>
<div class="cnblogs_code">
  <pre class="blockcode">jupyter kernelspec l
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP