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.Mon, 20 Sep 2021 01:28:54 +0200Unable to link Jupyter notebook to correct kernelhttps://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/A while ago I installed sage version 9.1 on my MacBook Pro running MacOS Mojave 10.14.6. That installation was from binary and was made in the MacOS Applications folder. Today I tried to install sage version 9.4, compiling from source. The install was in a subfolder of my user folder. The install seems fine, and I am able to run sage 9.4 from the command line.
Now I am trying to run 9.4 in a Jupyter notebook. After typing
./sage -n jupyter
or
./sage -n jupyterlab
in the root directory of my new installation things start well—the following banner comes up in the terminal,
┌────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22 │
│ Using Python 3.9.5. Type "help()" for help. │
└────────────────────────────────────────────────┘
Please wait while the Jupyterlab server starts...
[I 18:26:42.688 LabApp] JupyterLab extension loaded from /Users/williamorrick2/sage- 9.4/local/lib/python3.9/site-packages/jupyterlab
[I 18:26:42.688 LabApp] JupyterLab application directory is /Users/williamorrick2/sage-9.4/local/share/jupyter/lab
[I 18:26:42.694 LabApp] Serving notebooks from local directory: /Users/williamorrick2/sage-9.4
[I 18:26:42.694 LabApp] Jupyter Notebook 6.1.1 is running at:
[I 18:26:42.694 LabApp] http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:42.704 LabApp]
To access the notebook, open this file in a browser:
file:///Users/williamorrick2/Library/Jupyter/runtime/nbserver-2218-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:45.498 LabApp] Build is up to date
[I 18:26:45.750 LabApp] Kernel started: 8500f3e9-4730-4c6d-8363-5686721acc8e, name: sagemath
—but when the notebook opens (either in Jupyter notebook or in Jupyterlab) the kernel is sage 9.1 rather than 9.4. Furthermore I am unable to execute any code. In the terminal, immediately following the lines quoted above, I get a bunch of messages like
> /Applications/SageMath-9.1.app/Contents/Resources/sage/local/bin/sage: line 619: /Users/williamorrick2/sage-9.4/local/bin/python2: No such file or directory
which suggest that Jupyter is running the old kernel in the Applications folder, and that it is looking for python2 under my new installation, which only contains python3.
How do I go about correcting this?Fri, 17 Sep 2021 01:35:47 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/Comment by Will Orrick for <p>A while ago I installed sage version 9.1 on my MacBook Pro running MacOS Mojave 10.14.6. That installation was from binary and was made in the MacOS Applications folder. Today I tried to install sage version 9.4, compiling from source. The install was in a subfolder of my user folder. The install seems fine, and I am able to run sage 9.4 from the command line.</p>
<p>Now I am trying to run 9.4 in a Jupyter notebook. After typing</p>
<pre><code>./sage -n jupyter
</code></pre>
<p>or</p>
<pre><code>./sage -n jupyterlab
</code></pre>
<p>in the root directory of my new installation things start well—the following banner comes up in the terminal,</p>
<pre><code>┌────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22 │
│ Using Python 3.9.5. Type "help()" for help. │
└────────────────────────────────────────────────┘
Please wait while the Jupyterlab server starts...
[I 18:26:42.688 LabApp] JupyterLab extension loaded from /Users/williamorrick2/sage- 9.4/local/lib/python3.9/site-packages/jupyterlab
[I 18:26:42.688 LabApp] JupyterLab application directory is /Users/williamorrick2/sage-9.4/local/share/jupyter/lab
[I 18:26:42.694 LabApp] Serving notebooks from local directory: /Users/williamorrick2/sage-9.4
[I 18:26:42.694 LabApp] Jupyter Notebook 6.1.1 is running at:
[I 18:26:42.694 LabApp] http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:42.704 LabApp]
To access the notebook, open this file in a browser:
file:///Users/williamorrick2/Library/Jupyter/runtime/nbserver-2218-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:45.498 LabApp] Build is up to date
[I 18:26:45.750 LabApp] Kernel started: 8500f3e9-4730-4c6d-8363-5686721acc8e, name: sagemath
</code></pre>
<p>—but when the notebook opens (either in Jupyter notebook or in Jupyterlab) the kernel is sage 9.1 rather than 9.4. Furthermore I am unable to execute any code. In the terminal, immediately following the lines quoted above, I get a bunch of messages like</p>
<pre><code>> /Applications/SageMath-9.1.app/Contents/Resources/sage/local/bin/sage: line 619: /Users/williamorrick2/sage-9.4/local/bin/python2: No such file or directory
</code></pre>
<p>which suggest that Jupyter is running the old kernel in the Applications folder, and that it is looking for python2 under my new installation, which only contains python3.</p>
<p>How do I go about correcting this?</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59100#post-id-59100Thinking about this some more, perhaps it makes sense. I started up sage 9.4 in my local user directory, which then started up jupyter, which then attempted to use an older sage 9.1 kernel. It makes some sort of sense that sage 9.1 wouldn't know where to look for things.Sun, 19 Sep 2021 04:03:15 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59100#post-id-59100Comment by Will Orrick for <p>A while ago I installed sage version 9.1 on my MacBook Pro running MacOS Mojave 10.14.6. That installation was from binary and was made in the MacOS Applications folder. Today I tried to install sage version 9.4, compiling from source. The install was in a subfolder of my user folder. The install seems fine, and I am able to run sage 9.4 from the command line.</p>
<p>Now I am trying to run 9.4 in a Jupyter notebook. After typing</p>
<pre><code>./sage -n jupyter
</code></pre>
<p>or</p>
<pre><code>./sage -n jupyterlab
</code></pre>
<p>in the root directory of my new installation things start well—the following banner comes up in the terminal,</p>
<pre><code>┌────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22 │
│ Using Python 3.9.5. Type "help()" for help. │
└────────────────────────────────────────────────┘
Please wait while the Jupyterlab server starts...
[I 18:26:42.688 LabApp] JupyterLab extension loaded from /Users/williamorrick2/sage- 9.4/local/lib/python3.9/site-packages/jupyterlab
[I 18:26:42.688 LabApp] JupyterLab application directory is /Users/williamorrick2/sage-9.4/local/share/jupyter/lab
[I 18:26:42.694 LabApp] Serving notebooks from local directory: /Users/williamorrick2/sage-9.4
[I 18:26:42.694 LabApp] Jupyter Notebook 6.1.1 is running at:
[I 18:26:42.694 LabApp] http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:42.704 LabApp]
To access the notebook, open this file in a browser:
file:///Users/williamorrick2/Library/Jupyter/runtime/nbserver-2218-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:45.498 LabApp] Build is up to date
[I 18:26:45.750 LabApp] Kernel started: 8500f3e9-4730-4c6d-8363-5686721acc8e, name: sagemath
</code></pre>
<p>—but when the notebook opens (either in Jupyter notebook or in Jupyterlab) the kernel is sage 9.1 rather than 9.4. Furthermore I am unable to execute any code. In the terminal, immediately following the lines quoted above, I get a bunch of messages like</p>
<pre><code>> /Applications/SageMath-9.1.app/Contents/Resources/sage/local/bin/sage: line 619: /Users/williamorrick2/sage-9.4/local/bin/python2: No such file or directory
</code></pre>
<p>which suggest that Jupyter is running the old kernel in the Applications folder, and that it is looking for python2 under my new installation, which only contains python3.</p>
<p>How do I go about correcting this?</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59097#post-id-59097My problem has been solved--see my answer and the better answer of Masacroso--but one mystery remains, namely why my sage 9.1 kernel was non-functional. (The kernel died as soon as I tried to run any code in the notebook.) Presumably this is some kind of path problem: the sage 9.1 kernel was looking for things it needed in my user directory rather than the Applications folder and not finding them.Sun, 19 Sep 2021 00:22:27 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59097#post-id-59097Answer by Will Orrick for <p>A while ago I installed sage version 9.1 on my MacBook Pro running MacOS Mojave 10.14.6. That installation was from binary and was made in the MacOS Applications folder. Today I tried to install sage version 9.4, compiling from source. The install was in a subfolder of my user folder. The install seems fine, and I am able to run sage 9.4 from the command line.</p>
<p>Now I am trying to run 9.4 in a Jupyter notebook. After typing</p>
<pre><code>./sage -n jupyter
</code></pre>
<p>or</p>
<pre><code>./sage -n jupyterlab
</code></pre>
<p>in the root directory of my new installation things start well—the following banner comes up in the terminal,</p>
<pre><code>┌────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22 │
│ Using Python 3.9.5. Type "help()" for help. │
└────────────────────────────────────────────────┘
Please wait while the Jupyterlab server starts...
[I 18:26:42.688 LabApp] JupyterLab extension loaded from /Users/williamorrick2/sage- 9.4/local/lib/python3.9/site-packages/jupyterlab
[I 18:26:42.688 LabApp] JupyterLab application directory is /Users/williamorrick2/sage-9.4/local/share/jupyter/lab
[I 18:26:42.694 LabApp] Serving notebooks from local directory: /Users/williamorrick2/sage-9.4
[I 18:26:42.694 LabApp] Jupyter Notebook 6.1.1 is running at:
[I 18:26:42.694 LabApp] http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:42.704 LabApp]
To access the notebook, open this file in a browser:
file:///Users/williamorrick2/Library/Jupyter/runtime/nbserver-2218-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:45.498 LabApp] Build is up to date
[I 18:26:45.750 LabApp] Kernel started: 8500f3e9-4730-4c6d-8363-5686721acc8e, name: sagemath
</code></pre>
<p>—but when the notebook opens (either in Jupyter notebook or in Jupyterlab) the kernel is sage 9.1 rather than 9.4. Furthermore I am unable to execute any code. In the terminal, immediately following the lines quoted above, I get a bunch of messages like</p>
<pre><code>> /Applications/SageMath-9.1.app/Contents/Resources/sage/local/bin/sage: line 619: /Users/williamorrick2/sage-9.4/local/bin/python2: No such file or directory
</code></pre>
<p>which suggest that Jupyter is running the old kernel in the Applications folder, and that it is looking for python2 under my new installation, which only contains python3.</p>
<p>How do I go about correcting this?</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?answer=59084#post-id-59084The fix I found was to remove the folder sagemath from the following folder:
/Users/williamorrick2/Library/Jupyter/kernels
The kernel.json file in the sagemath folder had been directing Jupyter to the kernel of my old installation.
I found this idea at [this StackOverflow post](https://stackoverflow.com/a/31976697).
**Added:** Masacroso's answer provides, I think, the best general approach to such problems, something I would have learned if I'd delved into the other answers in the StackOverflow post linked above. The reason I'm accepting my own answer is that I think it may be useful to further MacOS users who visit this question to know the precise identity of the file causing the problem.Sat, 18 Sep 2021 00:57:01 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?answer=59084#post-id-59084Comment by slelievre for <p>The fix I found was to remove the folder sagemath from the following folder:</p>
<p>/Users/williamorrick2/Library/Jupyter/kernels</p>
<p>The kernel.json file in the sagemath folder had been directing Jupyter to the kernel of my old installation.</p>
<p>I found this idea at <a href="https://stackoverflow.com/a/31976697">this StackOverflow post</a>.</p>
<p><strong>Added:</strong> Masacroso's answer provides, I think, the best general approach to such problems, something I would have learned if I'd delved into the other answers in the StackOverflow post linked above. The reason I'm accepting my own answer is that I think it may be useful to further MacOS users who visit this question to know the precise identity of the file causing the problem.</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59103#post-id-59103You can accept your own answer to mark the question as solved.Mon, 20 Sep 2021 01:28:54 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59103#post-id-59103Answer by slelievre for <p>A while ago I installed sage version 9.1 on my MacBook Pro running MacOS Mojave 10.14.6. That installation was from binary and was made in the MacOS Applications folder. Today I tried to install sage version 9.4, compiling from source. The install was in a subfolder of my user folder. The install seems fine, and I am able to run sage 9.4 from the command line.</p>
<p>Now I am trying to run 9.4 in a Jupyter notebook. After typing</p>
<pre><code>./sage -n jupyter
</code></pre>
<p>or</p>
<pre><code>./sage -n jupyterlab
</code></pre>
<p>in the root directory of my new installation things start well—the following banner comes up in the terminal,</p>
<pre><code>┌────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22 │
│ Using Python 3.9.5. Type "help()" for help. │
└────────────────────────────────────────────────┘
Please wait while the Jupyterlab server starts...
[I 18:26:42.688 LabApp] JupyterLab extension loaded from /Users/williamorrick2/sage- 9.4/local/lib/python3.9/site-packages/jupyterlab
[I 18:26:42.688 LabApp] JupyterLab application directory is /Users/williamorrick2/sage-9.4/local/share/jupyter/lab
[I 18:26:42.694 LabApp] Serving notebooks from local directory: /Users/williamorrick2/sage-9.4
[I 18:26:42.694 LabApp] Jupyter Notebook 6.1.1 is running at:
[I 18:26:42.694 LabApp] http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:42.704 LabApp]
To access the notebook, open this file in a browser:
file:///Users/williamorrick2/Library/Jupyter/runtime/nbserver-2218-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:45.498 LabApp] Build is up to date
[I 18:26:45.750 LabApp] Kernel started: 8500f3e9-4730-4c6d-8363-5686721acc8e, name: sagemath
</code></pre>
<p>—but when the notebook opens (either in Jupyter notebook or in Jupyterlab) the kernel is sage 9.1 rather than 9.4. Furthermore I am unable to execute any code. In the terminal, immediately following the lines quoted above, I get a bunch of messages like</p>
<pre><code>> /Applications/SageMath-9.1.app/Contents/Resources/sage/local/bin/sage: line 619: /Users/williamorrick2/sage-9.4/local/bin/python2: No such file or directory
</code></pre>
<p>which suggest that Jupyter is running the old kernel in the Applications folder, and that it is looking for python2 under my new installation, which only contains python3.</p>
<p>How do I go about correcting this?</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?answer=59075#post-id-59075Make sure `sage` points to the new Sage.
You could try `which sage` to check where the shell finds something called `sage`.
Then in case it is a symlink you could locate where it points to with
ls -halF $(which sage)
In case `which sage` returned `/usr/local/bin/sage`
you can replace the symlink using
ln -sf /Users/williamorrick2/sage-9.4/sage /usr/local/bin
or, if that gives a permission error, the same with `sudo`:
sudo ln -sf /Users/williamorrick2/sage-9.4/sage /usr/local/binFri, 17 Sep 2021 07:24:31 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?answer=59075#post-id-59075Comment by slelievre for <p>Make sure <code>sage</code> points to the new Sage.</p>
<p>You could try <code>which sage</code> to check where the shell finds something called <code>sage</code>.</p>
<p>Then in case it is a symlink you could locate where it points to with</p>
<pre><code>ls -halF $(which sage)
</code></pre>
<p>In case <code>which sage</code> returned <code>/usr/local/bin/sage</code>
you can replace the symlink using</p>
<pre><code>ln -sf /Users/williamorrick2/sage-9.4/sage /usr/local/bin
</code></pre>
<p>or, if that gives a permission error, the same with <code>sudo</code>:</p>
<pre><code>sudo ln -sf /Users/williamorrick2/sage-9.4/sage /usr/local/bin
</code></pre>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59102#post-id-59102If you would like to be able to start Sage from anywhere by typing `sage`, run this line:
ln -s /Users/williamorrick2/sage-9.4/sage /usr/local/bin
(or same with sudo if you get a permission error).
To undo:
rm /usr/local/bin/sage
(or same with sudo if this fails with a permission error).Mon, 20 Sep 2021 01:28:05 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59102#post-id-59102Comment by Will Orrick for <p>Make sure <code>sage</code> points to the new Sage.</p>
<p>You could try <code>which sage</code> to check where the shell finds something called <code>sage</code>.</p>
<p>Then in case it is a symlink you could locate where it points to with</p>
<pre><code>ls -halF $(which sage)
</code></pre>
<p>In case <code>which sage</code> returned <code>/usr/local/bin/sage</code>
you can replace the symlink using</p>
<pre><code>ln -sf /Users/williamorrick2/sage-9.4/sage /usr/local/bin
</code></pre>
<p>or, if that gives a permission error, the same with <code>sudo</code>:</p>
<pre><code>sudo ln -sf /Users/williamorrick2/sage-9.4/sage /usr/local/bin
</code></pre>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59078#post-id-59078Thanks for your message. In my old installation I never ran sage from the command line--I had a sage icon in my dock and always started sage with that--and so may never have had occasion to create any symlinks; "which sage" returns nothing. I've added some relevant detail to my question, which, I think, shows that it really is sage 9.4 that is starting up. When I say I type "sage", I'm actually switching to the root directory of my new installation and typing "./sage".Fri, 17 Sep 2021 12:51:54 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59078#post-id-59078Answer by Masacroso for <p>A while ago I installed sage version 9.1 on my MacBook Pro running MacOS Mojave 10.14.6. That installation was from binary and was made in the MacOS Applications folder. Today I tried to install sage version 9.4, compiling from source. The install was in a subfolder of my user folder. The install seems fine, and I am able to run sage 9.4 from the command line.</p>
<p>Now I am trying to run 9.4 in a Jupyter notebook. After typing</p>
<pre><code>./sage -n jupyter
</code></pre>
<p>or</p>
<pre><code>./sage -n jupyterlab
</code></pre>
<p>in the root directory of my new installation things start well—the following banner comes up in the terminal,</p>
<pre><code>┌────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22 │
│ Using Python 3.9.5. Type "help()" for help. │
└────────────────────────────────────────────────┘
Please wait while the Jupyterlab server starts...
[I 18:26:42.688 LabApp] JupyterLab extension loaded from /Users/williamorrick2/sage- 9.4/local/lib/python3.9/site-packages/jupyterlab
[I 18:26:42.688 LabApp] JupyterLab application directory is /Users/williamorrick2/sage-9.4/local/share/jupyter/lab
[I 18:26:42.694 LabApp] Serving notebooks from local directory: /Users/williamorrick2/sage-9.4
[I 18:26:42.694 LabApp] Jupyter Notebook 6.1.1 is running at:
[I 18:26:42.694 LabApp] http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:42.694 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:42.704 LabApp]
To access the notebook, open this file in a browser:
file:///Users/williamorrick2/Library/Jupyter/runtime/nbserver-2218-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
or http://127.0.0.1:8888/?token=ba7dda9e8563ac920c9dd6ae2ab402980df04273ce90c616
[I 18:26:45.498 LabApp] Build is up to date
[I 18:26:45.750 LabApp] Kernel started: 8500f3e9-4730-4c6d-8363-5686721acc8e, name: sagemath
</code></pre>
<p>—but when the notebook opens (either in Jupyter notebook or in Jupyterlab) the kernel is sage 9.1 rather than 9.4. Furthermore I am unable to execute any code. In the terminal, immediately following the lines quoted above, I get a bunch of messages like</p>
<pre><code>> /Applications/SageMath-9.1.app/Contents/Resources/sage/local/bin/sage: line 619: /Users/williamorrick2/sage-9.4/local/bin/python2: No such file or directory
</code></pre>
<p>which suggest that Jupyter is running the old kernel in the Applications folder, and that it is looking for python2 under my new installation, which only contains python3.</p>
<p>How do I go about correcting this?</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?answer=59089#post-id-59089Maybe this will help to someone. I dont have a Mac but in Ubuntu I do the following (and probably it works also in any other system): what I do is to link sagemath to a previous installation of jupyter in the system, to do this I just need first to delete any previous kernel of sagemath in Jupyter (if there is someone), running
jupyter kernelspec uninstall name-of-old-sagemath-kernel
in a terminal, but previously I run
jupyter kernelspec list
to know the kernels installed in jupyter. Once I have uninstalled from jupyter any old kernel of sagemath then I install the new one, running
jupyter kernelspec install --user /home/Masacroso/Documents/SageMath/local/share/jupyter/kernels/sagemath/
where I had sagemath unzipped in the folder `/home/Masacroso/Documents/Sagemath`. Then when I run `jupyter lab` from a terminal then one of the supported languages is sagemath.Sat, 18 Sep 2021 09:42:55 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?answer=59089#post-id-59089Comment by Masacroso for <p>Maybe this will help to someone. I dont have a Mac but in Ubuntu I do the following (and probably it works also in any other system): what I do is to link sagemath to a previous installation of jupyter in the system, to do this I just need first to delete any previous kernel of sagemath in Jupyter (if there is someone), running</p>
<pre><code>jupyter kernelspec uninstall name-of-old-sagemath-kernel
</code></pre>
<p>in a terminal, but previously I run</p>
<pre><code>jupyter kernelspec list
</code></pre>
<p>to know the kernels installed in jupyter. Once I have uninstalled from jupyter any old kernel of sagemath then I install the new one, running</p>
<pre><code>jupyter kernelspec install --user /home/Masacroso/Documents/SageMath/local/share/jupyter/kernels/sagemath/
</code></pre>
<p>where I had sagemath unzipped in the folder <code>/home/Masacroso/Documents/Sagemath</code>. Then when I run <code>jupyter lab</code> from a terminal then one of the supported languages is sagemath.</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59093#post-id-59093@Will I supposeSat, 18 Sep 2021 17:48:43 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59093#post-id-59093Comment by Will Orrick for <p>Maybe this will help to someone. I dont have a Mac but in Ubuntu I do the following (and probably it works also in any other system): what I do is to link sagemath to a previous installation of jupyter in the system, to do this I just need first to delete any previous kernel of sagemath in Jupyter (if there is someone), running</p>
<pre><code>jupyter kernelspec uninstall name-of-old-sagemath-kernel
</code></pre>
<p>in a terminal, but previously I run</p>
<pre><code>jupyter kernelspec list
</code></pre>
<p>to know the kernels installed in jupyter. Once I have uninstalled from jupyter any old kernel of sagemath then I install the new one, running</p>
<pre><code>jupyter kernelspec install --user /home/Masacroso/Documents/SageMath/local/share/jupyter/kernels/sagemath/
</code></pre>
<p>where I had sagemath unzipped in the folder <code>/home/Masacroso/Documents/Sagemath</code>. Then when I run <code>jupyter lab</code> from a terminal then one of the supported languages is sagemath.</p>
https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59091#post-id-59091Thanks. The install part wouldn't have been necessary in my case because the sage installation takes care of that. But "jupyter kernelspec list" would have alerted me to the copy of the sagemath kernel in /Users/williamorrick2/Library/Jupyter/kernels, which apparently takes precedence over the copy in the local sage directory, and which I could have then uninstalled. I guess uninstalling has the same effect as the deletion procedure I did?Sat, 18 Sep 2021 16:40:23 +0200https://ask.sagemath.org/question/59071/unable-to-link-jupyter-notebook-to-correct-kernel/?comment=59091#post-id-59091