Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-updates > by-pkgid > b9a6a1b9f2781444d2917afd8e4421ab > files > 972

ipython-doc-2.3.0-2.2.mga5.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Running a notebook server &mdash; IPython 2.3.0 documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.3.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="IPython 2.3.0 documentation" href="../index.html" />
    <link rel="up" title="The IPython notebook" href="index.html" />
    <link rel="next" title="Security in IPython notebooks" href="security.html" />
    <link rel="prev" title="Converting notebooks to other formats" href="nbconvert.html" /> 
  </head>
  <body>

<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
<a href="http://ipython.org/"><img src="../_static/logo.png" border="0" alt="IPython Documentation"/></a>
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="security.html" title="Security in IPython notebooks"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="nbconvert.html" title="Converting notebooks to other formats"
             accesskey="P">previous</a> |</li>
        <li><a href="http://ipython.org">home</a>|&nbsp;</li>
        <li><a href="../search.html">search</a>|&nbsp;</li>
       <li><a href="../index.html">documentation </a> &raquo;</li>

          <li><a href="index.html" accesskey="U">The IPython notebook</a> &raquo;</li> 
      </ul>
    </div>

      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Running a notebook server</a><ul>
<li><a class="reference internal" href="#securing-a-notebook-server">Securing a notebook server</a></li>
<li><a class="reference internal" href="#running-a-public-notebook-server">Running a public notebook server</a></li>
<li><a class="reference internal" href="#running-with-a-different-url-prefix">Running with a different URL prefix</a></li>
<li><a class="reference internal" href="#using-a-different-notebook-store">Using a different notebook store</a></li>
<li><a class="reference internal" href="#known-issues">Known issues</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="nbconvert.html"
                        title="previous chapter">Converting notebooks to other formats</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="security.html"
                        title="next chapter">Security in IPython notebooks</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/notebook/public_server.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="running-a-notebook-server">
<span id="working-remotely"></span><h1>Running a notebook server<a class="headerlink" href="#running-a-notebook-server" title="Permalink to this headline">¶</a></h1>
<p>The  <a class="reference internal" href="notebook.html#htmlnotebook"><em>IPython notebook</em></a> web-application is based on a
server-client structure.  This server uses a <a class="reference internal" href="../overview.html#ipythonzmq"><em>two-process kernel
architecture</em></a> based on <a class="reference external" href="http://zeromq.org">ZeroMQ</a>, as well as <a class="reference external" href="http://www.tornadoweb.org">Tornado</a> for serving
HTTP requests. By default, a notebook server runs on <a class="reference external" href="http://127.0.0.1:8888/">http://127.0.0.1:8888/</a>
and is accessible only from <cite>localhost</cite>. This document describes how you can
<a class="reference internal" href="#notebook-server-security"><em>secure a notebook server</em></a> and how to <a class="reference internal" href="#notebook-public-server"><em>run it on
a public interface</em></a>.</p>
<div class="section" id="securing-a-notebook-server">
<span id="notebook-server-security"></span><h2>Securing a notebook server<a class="headerlink" href="#securing-a-notebook-server" title="Permalink to this headline">¶</a></h2>
<p>You can protect your notebook server with a simple single password by
setting the <tt class="xref py py-attr docutils literal"><span class="pre">NotebookApp.password</span></tt> configurable. You can prepare a
hashed password using the function <a class="reference internal" href="../api/generated/IPython.lib.security.html#IPython.lib.security.passwd" title="IPython.lib.security.passwd"><tt class="xref py py-func docutils literal"><span class="pre">IPython.lib.security.passwd()</span></tt></a>:</p>
<div class="highlight-ipython"><div class="highlight"><pre><span class="gp">In [1]: </span><span class="kn">from</span> <span class="nn">IPython.lib</span> <span class="kn">import</span> <span class="n">passwd</span>
<span class="gp">In [2]: </span><span class="n">passwd</span><span class="p">()</span>
<span class="go">Enter password:</span>
<span class="go">Verify password:</span>
<span class="gh">Out[2]: </span><span class="go">&#39;sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed&#39;</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><a class="reference internal" href="../api/generated/IPython.lib.security.html#IPython.lib.security.passwd" title="IPython.lib.security.passwd"><tt class="xref py py-func docutils literal"><span class="pre">passwd()</span></tt></a> can also take the password as a string
argument. <strong>Do not</strong> pass it as an argument inside an IPython session, as it
will be saved in your input history.</p>
</div>
<p>You can then add this to your <tt class="file docutils literal"><span class="pre">ipython_notebook_config.py</span></tt>, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre># Password to use for web authentication
c = get_config()
c.NotebookApp.password =
u&#39;sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed&#39;
</pre></div>
</div>
<p>When using a password, it is a good idea to also use SSL, so that your
password is not sent unencrypted by your browser. You can start the notebook
to communicate via a secure protocol mode using a self-signed certificate with
the command:</p>
<div class="highlight-python"><div class="highlight"><pre>$ ipython notebook --certfile=mycert.pem
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>A self-signed certificate can be generated with <tt class="docutils literal"><span class="pre">openssl</span></tt>.  For example,
the following command will create a certificate valid for 365 days with
both the key and certificate data written to the same file:</p>
<div class="last highlight-python"><div class="highlight"><pre>$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
</pre></div>
</div>
</div>
<p>Your browser will warn you of a dangerous certificate because it is
self-signed.  If you want to have a fully compliant certificate that will not
raise warnings, it is possible (but rather involved) to obtain one,
as explained in detail in <a class="reference external" href="http://arstechnica.com/security/news/2009/12/how-to-get-set-with-a-secure-sertificate-for-free.ars">this tutorial</a>.</p>
<p>Keep in mind that when you enable SSL support, you will need to access the
notebook server over <tt class="docutils literal"><span class="pre">https://</span></tt>, not over plain <tt class="docutils literal"><span class="pre">http://</span></tt>.  The startup
message from the server prints this, but it is easy to overlook and think the
server is for some reason non-responsive.</p>
</div>
<div class="section" id="running-a-public-notebook-server">
<span id="notebook-public-server"></span><h2>Running a public notebook server<a class="headerlink" href="#running-a-public-notebook-server" title="Permalink to this headline">¶</a></h2>
<p>If you want to access your notebook server remotely via a web browser,
you can do the following.</p>
<p>Start by creating a certificate file and a hashed password, as explained
above.  Then create a custom profile for the notebook, with the following
command line, type:</p>
<div class="highlight-python"><div class="highlight"><pre>$ ipython profile create nbserver
</pre></div>
</div>
<p>In the profile directory just created, edit the file
<tt class="docutils literal"><span class="pre">ipython_notebook_config.py</span></tt>.  By default, the file has all fields
commented; the minimum set you need to uncomment and edit is the following:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">c</span> <span class="o">=</span> <span class="n">get_config</span><span class="p">()</span>

<span class="c"># Kernel config</span>
<span class="n">c</span><span class="o">.</span><span class="n">IPKernelApp</span><span class="o">.</span><span class="n">pylab</span> <span class="o">=</span> <span class="s">&#39;inline&#39;</span>  <span class="c"># if you want plotting support always</span>

<span class="c"># Notebook config</span>
<span class="n">c</span><span class="o">.</span><span class="n">NotebookApp</span><span class="o">.</span><span class="n">certfile</span> <span class="o">=</span> <span class="s">u&#39;/absolute/path/to/your/certificate/mycert.pem&#39;</span>
<span class="n">c</span><span class="o">.</span><span class="n">NotebookApp</span><span class="o">.</span><span class="n">ip</span> <span class="o">=</span> <span class="s">&#39;*&#39;</span>
<span class="n">c</span><span class="o">.</span><span class="n">NotebookApp</span><span class="o">.</span><span class="n">open_browser</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">c</span><span class="o">.</span><span class="n">NotebookApp</span><span class="o">.</span><span class="n">password</span> <span class="o">=</span> <span class="s">u&#39;sha1:bcd259ccf...[your hashed password here]&#39;</span>
<span class="c"># It is a good idea to put it on a known, fixed port</span>
<span class="n">c</span><span class="o">.</span><span class="n">NotebookApp</span><span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="mi">9999</span>
</pre></div>
</div>
<p>You can then start the notebook and access it later by pointing your browser
to <tt class="docutils literal"><span class="pre">https://your.host.com:9999</span></tt> with <tt class="docutils literal"><span class="pre">ipython</span> <span class="pre">notebook</span>
<span class="pre">--profile=nbserver</span></tt>.</p>
</div>
<div class="section" id="running-with-a-different-url-prefix">
<h2>Running with a different URL prefix<a class="headerlink" href="#running-with-a-different-url-prefix" title="Permalink to this headline">¶</a></h2>
<p>The notebook dashboard (the landing page with an overview
of the notebooks in your working directory) typically lives at the URL
<tt class="docutils literal"><span class="pre">http://localhost:8888/</span></tt>. If you prefer that it lives, together with the
rest of the notebook, under a sub-directory,
e.g. <tt class="docutils literal"><span class="pre">http://localhost:8888/ipython/</span></tt>, you can do so with
configuration options like the following (see above for instructions about
modifying <tt class="docutils literal"><span class="pre">ipython_notebook_config.py</span></tt>):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">c</span><span class="o">.</span><span class="n">NotebookApp</span><span class="o">.</span><span class="n">base_url</span> <span class="o">=</span> <span class="s">&#39;/ipython/&#39;</span>
<span class="n">c</span><span class="o">.</span><span class="n">NotebookApp</span><span class="o">.</span><span class="n">webapp_settings</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;static_url_prefix&#39;</span><span class="p">:</span><span class="s">&#39;/ipython/static/&#39;</span><span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="using-a-different-notebook-store">
<h2>Using a different notebook store<a class="headerlink" href="#using-a-different-notebook-store" title="Permalink to this headline">¶</a></h2>
<p>By default, the notebook server stores the notebook documents that it saves as
files in the working directory of the notebook server, also known as the
<tt class="docutils literal"><span class="pre">notebook_dir</span></tt>. This  logic is implemented in the
<tt class="xref py py-class docutils literal"><span class="pre">FileNotebookManager</span></tt> class. However, the server can be configured to
use a different notebook manager class, which can
store the notebooks in a different format.</p>
<p>The <a class="reference external" href="https://github.com/rgbkrk/bookstore">bookstore</a> package currently allows users to store notebooks on Rackspace
CloudFiles or OpenStack Swift based object stores.</p>
<p>Writing a notebook manager is as simple as extending the base class
<tt class="xref py py-class docutils literal"><span class="pre">NotebookManager</span></tt>. The <a class="reference external" href="https://github.com/khinsen/simple_notebook_manager">simple_notebook_manager</a> provides a great example
of an in memory notebook manager, created solely for the purpose of
illustrating the notebook manager API.</p>
</div>
<div class="section" id="known-issues">
<h2>Known issues<a class="headerlink" href="#known-issues" title="Permalink to this headline">¶</a></h2>
<p>When behind a proxy, especially if your system or browser is set to autodetect
the proxy, the notebook web application might fail to connect to the server&#8217;s
websockets, and present you with a warning at startup. In this case, you need
to configure your system not to use the proxy for the server&#8217;s address.</p>
<p>For example, in Firefox, go to the Preferences panel, Advanced section,
Network tab, click &#8216;Settings...&#8217;, and add the address of the notebook server
to the &#8216;No proxy for&#8217; field.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="security.html" title="Security in IPython notebooks"
             >next</a> |</li>
        <li class="right" >
          <a href="nbconvert.html" title="Converting notebooks to other formats"
             >previous</a> |</li>
        <li><a href="http://ipython.org">home</a>|&nbsp;</li>
        <li><a href="../search.html">search</a>|&nbsp;</li>
       <li><a href="../index.html">documentation </a> &raquo;</li>

          <li><a href="index.html" >The IPython notebook</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright The IPython Development Team.
      Last updated on Jul 14, 2015.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>