ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 21 Oct 2015 20:37:52 +0200jupyter (ipython notebook) kernel math displayhttps://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/I'm trying to set up sage as a [jupyter](https://jupyter.org/) (ipython notebook 4.0+) kernel on my local machine.
To do this, I have installed sage in /usr/local/sage, and set up a kernel using the SageKernelSpec tool (following instructions [here](http://doc.sagemath.org/html/en/reference/repl/sage/repl/ipython_kernel/install.html)).
My sage kernel.json looks like this:
> {"display_name": "Sage 6.9", "argv": ["/usr/local/sage/sage", "-python", "-m", "sage.repl.ipython_kernel", "-f", "{connection_file}"]}
The kernel starts from within jupyter, and I am able to run sage. However, math text is not rendered. As an example:
x, y = var('x y')
show(x/y)
> \newcommand{\Bold}[1]{\mathbf{#1}}\frac{x}{y}
The problem seems to be that the notebook is not recognising and formatting mathjax input properly. I have tried manually linking the sage mathjax library to ipython using:
use_local_mathjax()
But it still does not work.
I *can* get a properly functioning sage notebook by entering:
sage -n ipython
in terminal, but when starting the notebook from my standard jupyter environment (i.e. choosing the kernel from the dropdown list), the mathtype is not rendered.
I can't work out what's going on... any pointers appreciated.
Thanks!Wed, 21 Oct 2015 03:25:38 +0200https://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/Answer by slelievre for <p>I'm trying to set up sage as a <a href="https://jupyter.org/">jupyter</a> (ipython notebook 4.0+) kernel on my local machine.</p>
<p>To do this, I have installed sage in /usr/local/sage, and set up a kernel using the SageKernelSpec tool (following instructions <a href="http://doc.sagemath.org/html/en/reference/repl/sage/repl/ipython_kernel/install.html">here</a>).</p>
<p>My sage kernel.json looks like this:</p>
<blockquote>
<p>{"display_name": "Sage 6.9", "argv": ["/usr/local/sage/sage", "-python", "-m", "sage.repl.ipython_kernel", "-f", "{connection_file}"]}</p>
</blockquote>
<p>The kernel starts from within jupyter, and I am able to run sage. However, math text is not rendered. As an example:</p>
<pre><code>x, y = var('x y')
show(x/y)
> \newcommand{\Bold}[1]{\mathbf{#1}}\frac{x}{y}
</code></pre>
<p>The problem seems to be that the notebook is not recognising and formatting mathjax input properly. I have tried manually linking the sage mathjax library to ipython using:</p>
<pre><code>use_local_mathjax()
</code></pre>
<p>But it still does not work.</p>
<p>I <em>can</em> get a properly functioning sage notebook by entering:</p>
<pre><code>sage -n ipython
</code></pre>
<p>in terminal, but when starting the notebook from my standard jupyter environment (i.e. choosing the kernel from the dropdown list), the mathtype is not rendered.</p>
<p>I can't work out what's going on... any pointers appreciated.</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/?answer=30170#post-id-30170This looks similar to what was fixed in [SageMath trac ticket 19374](http://trac.sagemath.org/ticket/19374), which was merged in SageMath 6.9 (but not in any previous beta release, including SageMath 6.9.rc3).
Related issues were solved more recently at [SageMath trac ticket 19373](http://trac.sagemath.org/ticket/19373)
and [SageMath trac ticket 19371](http://trac.sagemath.org/ticket/19371) and will likely be in the next beta release.
To follow beta releases, read [the sage-release mailing list](https://groups.google.com/forum/#!forum/sage-release).
Issues are also discussed on [sage-support](https://groups.google.com/forum/#!forum/sage-support) and [sage-devel](https://groups.google.com/forum/#!forum/sage-devel), see for instance [this thread on sage-support](https://groups.google.com/d/topic/sage-support/9XUytpCulcA/discussion).Wed, 21 Oct 2015 07:27:18 +0200https://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/?answer=30170#post-id-30170Comment by oscarbranson for <p>This looks similar to what was fixed in <a href="http://trac.sagemath.org/ticket/19374">SageMath trac ticket 19374</a>, which was merged in SageMath 6.9 (but not in any previous beta release, including SageMath 6.9.rc3).</p>
<p>Related issues were solved more recently at <a href="http://trac.sagemath.org/ticket/19373">SageMath trac ticket 19373</a>
and <a href="http://trac.sagemath.org/ticket/19371">SageMath trac ticket 19371</a> and will likely be in the next beta release.</p>
<p>To follow beta releases, read <a href="https://groups.google.com/forum/#!forum/sage-release">the sage-release mailing list</a>.</p>
<p>Issues are also discussed on <a href="https://groups.google.com/forum/#!forum/sage-support">sage-support</a> and <a href="https://groups.google.com/forum/#!forum/sage-devel">sage-devel</a>, see for instance <a href="https://groups.google.com/d/topic/sage-support/9XUytpCulcA/discussion">this thread on sage-support</a>.</p>
https://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/?comment=30186#post-id-30186Thanks. If I understand you correctly, I should either get a beta release, or wait for the next release (I'm running 6.9 at the moment)?
I'm intrigued by the differences between the notebook started by 'sage -n ipython' and the sage kernel added to jupyter by SageKernelSpec... it seems like it should be possible to make the 'sage -n ipython' kernel the default, but I'm not familiar enough with the jupyter architecture to work out how to do this!Wed, 21 Oct 2015 20:37:52 +0200https://ask.sagemath.org/question/30163/jupyter-ipython-notebook-kernel-math-display/?comment=30186#post-id-30186